Load a CBitmap dynamically

前端 未结 8 1784
情深已故
情深已故 2021-02-06 02:59

I have a Bitmap image that i want to load dynamically. But I am unable to load it.

CBitmap bmp;

bmp.LoadBitmap(\"c:\\\\aeimg\");

it does not

8条回答
  •  余生分开走
    2021-02-06 03:32

    According to CBitmap documentation: LoadBitmap() function takes resource identifier of the bitmap or resource id of the bitmap.

    You can't specify the path of the bitmap file.

    E.g.

    MyProject.rc
    ------------
    MYBMP      BITMAP  "res\myimage.bmp"
    

    and make sure that resource.h does not have any entry of MYBMP otherwise during preprocessing its replaced by id and ultimately LoadBitmap() will fail since application can't locate the resource as FindResource() fails.

    Now do this :

    CBitmap bmp;
    bmp.LoadBitmap(L"MYBMP");
    

    It will definitely load the bitmap.

提交回复
热议问题