Archived

This topic is now archived and is closed to further replies.

WM_PAINT and windows messaging

This topic is 5582 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

I have a program that changes the background of a window to a certain colour when clicked. This brush is temporarily created. I need to know how to find out when windows has finished doing all the painting on the window so that I can notify the window it can delete the brush. The WM_LBUTTONUP event is a temporary workaround simply because I have other times when the window disappears of the screen and comes back with the use of a scrollbar. Also, what if I send myself a custom message after I call the InvalidateRect function? Would that allow my message to be handled only after the WM_PAINT? BTW: WM_PAINT is handled right now default by Windows. I could still capture the message and then pass it on by simply calling the return DefWindowProc(blah blah blah....) to have Windows handle the rest of the stuff. [edited by - vlovich on September 2, 2002 12:54:04 PM]

Share this post


Link to post
Share on other sites
I would suggest just using a persistant brush that you free only when you plan to re-initializing it to a new color. Really, having a single brush GDI object hanging around in the background isn't going to cause anyone's Win98 to crash from GDI abuse.

GDI and brush handles are just pointers without the *, so you can just set it to NULL to start your app, and then just free the brush before you reassign it. Windows should be smart and ignore the call when a NULL parameter is supplied. If not (really loose pseudo-code because I can't remember the brush-API functions off the top of my head):

if(hBackgroundBrush) DestroyBrush(hBackgroundBrush);

- Air
- Lead Programmer : Hour 13 Studios

[edited by - Air on September 2, 2002 1:51:34 PM]

Share this post


Link to post
Share on other sites
The problem is that I have to get brushes i created previously back to repaint windows. i''m trying to figure out how to change the background of a window by using only the WM_SETWINDOWLONG. but i don''t know the byte off-set for background.

Share this post


Link to post
Share on other sites