Results 1 to 3 of 3

Thread: Continuous WM_PAINT

  1. #1

    Thread Starter
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402

    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 .

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    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.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width