Sign in to follow this  

win32 - WM_PAINT - getting stuff onto screen *FIXED

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just think of a small and simple win32 program, loads a bitmap, and put it onto the screen with a standard WM_PAINT message ... ie. the code for painting the stuff is in the WM_PAINT section... What I don't get is this: If the painting code is in the wm_paint, or somewhat triggered by the wm_paint, then the painting goes well. (like the BRICKS1.C in petzolds prog.windows book). ... But if I want to trigger that code from a function and not via the wm_paint, like calling a draw() from the gameloop, then it doesn't draw anything ... I'm a bit confused here and don't really know what to do (I want to draw the bitmap to the screen without using wm_paint, like if I made my splash screen or something). EDIT: I fixed it ... I think My draw function was starting with BeginPaint() and ending with EndPaint(). I changed that to hDC = GetDC(), and ended with ReleaseDC(), then it worked ... a bit similar to the RandRect.c in the same book... [Edited by - DarkSlayer on January 17, 2005 12:38:13 PM]

Share this post


Link to post
Share on other sites
This was similar to a problem I encountered some time ago. I would handle WM_PAINT messages by calling my own painting routine. The problem I had was that eventhough I would get and release the DC from my painting function the painting that was done wouldn't show up. I tried numerous tricks to try and fix it including validating/invalidating the window. The problem ended up being that the calls to BeginPaint and EndPaint were missing within the message code although I was calling those two functions from my painting routine. Moral of the story: Always call BeginPaint and EndPaint directly from the WM_PAINT case :)

Share this post


Link to post
Share on other sites

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this