winapi - Bitmap not being painted in Win32 C++ -
i have window using win32 , in message handler have case wm_paint, bitmap drawn in window. on running bitmap not drawn, there missing? need manually send wm_paint message?
here code have: http://pastebin.com/bi48lb0u
and wm_paint case:
case wm_paint: hdc = beginpaint(hwnd, &ps); bmp = loadbitmap(hinst, l"c:\\example.bmp"); memdcexercising = createcompatibledc(hdc); selectobject(memdcexercising, bmp); bitblt(hdc, 100, 100, 500, 500, memdcexercising, 0, 0, srccopy); deletedc(memdcexercising); deleteobject(bmp); endpaint(hwnd, &ps); break;
your bitmap doesn't show, because call loadbitmap returns null, due invalid lpbitmapname argument. documentation loadbitmap:
lpbitmapname [in]: pointer null-terminated string contains name of bitmap resource loaded. alternatively, parameter can consist of resource identifier in low-order word , 0 in high-order word. makeintresource macro can used create value.
in other words: loadbitmap can load bitmaps resources of type rt_bitmap (or predefined bitmaps provided system). if need load bitmap disk, use loadimage instead.
if need load image data other plain bitmap files, consider using windows imaging component.
Comments
Post a Comment