Clear/ Re-paint / Invalidate function?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • radders
    New Member
    • Jan 2007
    • 13

    Clear/ Re-paint / Invalidate function?

    Hi everyone, I've written a simple programme using Visual C++ that assigns the values of the mouse's coordinates to a set of variables each time the mouse is moved to a new position with a button pressed. It then draws a line between the new cursor position and the position stored in the variables, allowing you to sketch with the mouse. What I would like to do is assign a function to repaint the dialogue box to its initial setting (i.e. only containing a static text box of instructions and two push buttons) to a "clear drawing" push button, but don't know what function to use. A colleague suggested assigning the Invalidate() or Invalidate(TRUE ) function in the following manner:
    Code:
    this -> Invalidate()
    to the BN_CLICKED event of the push button, but it did not work. Any ideas or suggestions on how to get this working would be much appreciated,
    Thanks, Radders
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    You are drawing on a dialogue box?
    This is faily unusual in itself, are you drawing in the OnPaint handler (WM_PAINT message) or just in the mouse handlers?

    Invalidate just tells Windows that the dialogue needs redrawing (assuming this pointer is to the dialogue box) not to actually do the redraw. You need to call UpdateWindow after that to force the redraw.

    Try

    this->Invalidate() ;
    this->UpdateWindow() ;

    Comment

    Working...