none
ERROR FROM LOAD BITMAP RRS feed

  • Question

  • when i want to load the image from res to dialog i use my code below but it show the running error and i can't fix it!!! please help me!!!

    ***my code***

    CString sImage(“nam_doc.bmp”) ;

    CString pathFile = sImage;

    HBITMAP hBitmap;

    CImage pngImage;

    CBitmap pngBmg;

    CDC bmDC;

    CBitmap *p01dbmp;

    BITMAP bi;

    CClientDC dc(this);

    pngImage.Load(pathFile);

    pngBmg.Attach(pngImage.Detach());

    bmDC.CreateCompatibleDC(&dc);

    p01dbmp = bmDC.SelectObject(&pngBmg);

    pngBmg.GetBitmap(&bi);

    HBITMAP bmp = (HBITMAP)CopyImage((HBITMAP)pngBmg,IMAGE_BITMAP,141,151,LR_COPYDELETEORG);

    pictureBox.SetBitmap(bmp);

    and it's show the error

    /*

    Debug Assertion Failed!

    Program:...\bai tap lon\Lap trinh nang cao\baiTapLon\Debug\baiTapLon.exe

    File: c:\program files(x86)\microsoft visual studio 12.0\vc\atlmfc\include\atlimage.h

    Line:907

    Expression: m_hBitmap != 0

    For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts

    (Press Retry to debug the application)

    */

    Sunday, November 8, 2015 7:23 PM

Answers

  • Perhaps posting your question to the appropriate MSDN forum rather than "Training and Certification" (i.e. this forum addresses questions specific to Microsoft Certifications)
    Tuesday, November 10, 2015 1:35 PM
    Answerer