HBITMAP to Window

Started by
11 comments, last by b1gjo3 15 years, 11 months ago
Ok well i think you solved the original problem ( SelectObject() ), but I think you may have another one.

Why do you GetDC() after you create the window? Are you doing drawing right then? All of your client drawing should be done between BeginPaint() and EndPaint() and you get your DC from there so you shouldn't need to call GetDC(). And if for some reason you really do need a DC there, are you calling ReleaseDC()?

Only in two situations do you NOT call ReleaseDC() on a DC you retrieved with GetDC() and they are when the DC is a "Class DC" or a "Private DC". Which is to say you registered your window class with the styles of CS_CLASSDC or CS_OWNDC which give you a class and private DC respectively. If these are not in the WNDCLASSEX.style property, the GetDC() is getting a common DC from the system pool. Not calling ReleaseDC() on it is a memory leak.



*Note the difference between Class DC as it relates to the Window Class as registered with RegisterClass/RegisterClassEx and the C++ window class you have implemented which has a member that is an HDC.
"Being Irish he had an abiding sense of tragedy that sustainted him through the temporary periods of joy." -- W.B. Yeats
Advertisement
Quote:Original post by random_acts
LoadImage can't load JPEG and GIF files.

That was shortsighted of me. Too bad SHLoadImageFile() is only Windows Mobile.

ok i just got rid of myDC variable and used a HDC called SrcDC, and its working finally. Although changing the DC didnt solve my problem. I inserted LoadAnImage() right before the selectobject just to make sure the image would load correctly. and it did.

Now how come i can do this with small images, but it wont display bigger images?

thanks guys


[Edited by - b1gjo3 on May 10, 2008 4:33:40 PM]

This topic is closed to new replies.

Advertisement