|
-
Sep 13th, 2002, 09:25 PM
#1
Thread Starter
Frenzied Member
Continuous WM_PAINT
I am making a small Visual C++ program. It's supposed to generate a random number, ask the user for a number, compare the number with the generated number, and open a new window telling the user if he is correct or incorrect.
Now, I am using a painted window to display output. in WM_PAINT, I first get the window's area, then paints a filled rectangle and text to the window's hdc (which I obtained in WM_CREATE using the GetDC function). The problem is, the window KEEPS on repainting itself and I ran out of GDI resources in like ten seconds. Does anyone know what caused this WM_PAINT loop?
MicroBasic
Dragon Shadow Trainer
There is no good or evil in the world...only programmers and fools .
-
Sep 13th, 2002, 09:36 PM
#2
Frenzied Member
Call ValidateRect(hWnd, NULL) as the last line of your WM_PAINT handler. It tells windows to stop senting WM_PAINT until it needs to be done again. Otherwise, windows will send WM_PAINT until it gets a ValidateRect().
Z.
-
Sep 16th, 2002, 10:32 AM
#3
better yet, call BeginPaint and EndPaint in the WM_PAINT handler.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|