------------------
Blitting Bitmaps with the WinAPI
Move all your clean up code to a single location as well.
Your calls to DeleteObject also need to be modified:
DeleteObject(&PicslHB) becomes DeleteObject(PicslHB)
Also, where does TilesDC come from? Does it get initialized anywhere?
Just a couple suggestions...
-mordell
Yeah, sure... we are laughing WITH you ...
code:PAINSTRUCT ps;HBITMAP Pics1HB;BITMAP Pics1BM;HDC SrcDC;//hwndDlg is the HWND to the dialogcase WM_PAINT: BeginPaint(hwndDlg,&ps); Pics1HB=(HBITMAP) LoadImage(NULL, "pics1.bmp", IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE | LR_CREATEDIBSECTION); GetObject(Pics1HB,sizeof(Pics1BM),&Pics1BM); SrcDC=CreateCompatibleDC(TilesDC); SelectObject(SrcDC, Pics1HB); BitBlt(TilesDC,0,0,Pics1BM.bmWidth,Pics1BM.bmHeight,SrcDC,X,Y,SRCCOPY); DeleteObject(&Pics1HB); DeleteObject(&Pics1BM); DeleteObject(&SrcDC); EndPaint(hwndDlg,&ps);break;
This code works, yet as I said above, it works very poorly. Does anyone know how to make this code better? So i only have to load the bitmap once?
Thanks for reading!
Enix
[This message has been edited by Enix (edited December 14, 1999).]
After I changed the delete object code to what you said i should it now works. I think the reason it works now is because the SelectObject() function binds SrcDC with the handle to the bitmap, and to end this binding I have to delete SrcDC. I should have had this figured out hours ago, and would have, if msdn decided they would cover a usefull topic like this, but nooo...
THANKS AGAIN!!!!!!!!!!!!!!!!!!