i'm working on an application where i have to handle many bitmaps. Do i have to call CreateCompatibleDC, CreateCompatibleBitmap, SelectObject and PatBlt functions for every of the N bitmap i want to use or can i just do it once and change the bitmap selection using SelectObject on the same DC ? Many thanks TheTramp32
Posted on 2000-12-28 16:23:00 by TheTramp32
I'm assuming you're using the DC to hold a bitmap so you can blit it to your main window. You can keep re-using the same DC for all the bitmaps. You also don't have to CreateCompatibleBitmap, just load your bitmap resource, or etc, and select it in. Just don't loose the orgiuonal default bitmap of th DC so you can select it back in before you destroy the DC
Posted on 2000-12-28 23:16:00 by Ernie
;This Code will paint the bitmap object to the screen assuming that 'hWnd' is the window handle, note: you have to have a bitmap object to select in the DC, if you are loading the bmp from a file you will have to use CreateDIBitmap to load the bitmap into a selectable object. ;--------------------------------- .DATA hWnd dd 0 hDC dd 0 memDC dd 0 hWidth dd 0 hHeight dd 0 .DATA lpPaint PAINTSTRUCT <> ;--------------------------------- WM_CREATE: invoke GetDC,hWnd mov hDC,eax invoke CreateCompatibleDC,hDC mov memDC,eax ;--------------------------------- WM_PAINT: invoke BeginPaint,hWnd,addr lpPaint invoke BitBlt,hDC,0,0,hWidth,hHeight,memDC,0,0,SRCCOPY invoke EndPaint,hWnd,addr lpPaint ;--------------------------------- ;Anytime you want to put the bitmap into the memdc... invoke SelectObject,memDC,hBmp ;Your bitmap file ;Anytime you want to change the bitmap... invoke DeleteObject,hBmp ;Your bitmap file invoke SelectObject,memDC,hBmp2 ;Your bitmap file
Posted on 2000-12-29 03:11:00 by dork
Many thanks, now i'm trying ...
Posted on 2000-12-29 03:21:00 by TheTramp32