locked
HBITMAP handle error while loading bitmap from resource file RRS feed

  • Question

  • Hi

    I am trying to load the bitmap file from resource files. i am using visual C++ right now and sample code is as below.

    HBITMAP hBmp = NULL;

    CBitmap bmpBitmap;

    i tried two load this files in two ways but both are giving me error getting the HBITMAP handle,

    ###################First OPTION##################

     hBmp = (HBITMAP)::LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(101));

    ################SECOND OPTION#############################

    bmpBitmap.LoadBitmap(IDB_BITMAP1);

    hBmp = (HBITMAP)bmpBitmap;

    #######################################

    both the ways i am getting the error at hBmp "0Xadress:Unused?? Error CXX0030: Expression cannot be evaluated"

    Since i am using this handle later on to edit my image, resulting output image is not correct. So can anyone please help me out with this? i am stuck here since 3 days.

    Thanks a lot in advance

    gpl

    Friday, February 24, 2012 6:20 PM

Answers

  • I think that since the value is not 0x00000000, the operation succeeded. To confirm this, check the value returned by the second LoadBitmap. It should be nonzero. You can ignore these confusing messages displayed by Debugger.



    • Edited by Viorel_MVP Friday, February 24, 2012 7:31 PM
    • Proposed as answer by Jesse Jiang Monday, February 27, 2012 2:57 AM
    • Marked as answer by Jesse Jiang Tuesday, March 6, 2012 2:42 AM
    Friday, February 24, 2012 7:31 PM

All replies

  • I think that since the value is not 0x00000000, the operation succeeded. To confirm this, check the value returned by the second LoadBitmap. It should be nonzero. You can ignore these confusing messages displayed by Debugger.



    • Edited by Viorel_MVP Friday, February 24, 2012 7:31 PM
    • Proposed as answer by Jesse Jiang Monday, February 27, 2012 2:57 AM
    • Marked as answer by Jesse Jiang Tuesday, March 6, 2012 2:42 AM
    Friday, February 24, 2012 7:31 PM
  • Never mind.. if i ignore that debug part then it's working now... thanks for the help though.

    gpl

    • Proposed as answer by Jesse Jiang Thursday, March 1, 2012 6:56 AM
    Friday, February 24, 2012 8:48 PM