Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When all or part of your windows is out-of-date (called "invalid"), then the message loop will end up getting two messages: WM_ERASEBKGND and then WM_PAINT. The typical way for a Windows application to draw is to draw everything in the WM_ERASEBKGND and WM_PAINT handlers. (I'm not an MFC expert, but I believe WM_PAINT corresponds to OnDraw in MFC.)</p> <p>So the normal way to handle this would be for the mouse move handler to record the stroke (as it does) and then mark the window as invalid. This would eventually cause the line to be draw. However, there could be a slight delay, and it could cause flicker. The delay is probably insignificant on a modern computer (but Scribble is old). There are various ways to deal with the flicker.</p> <p>The Scribble author appears to have chosen to handle the delay and the flicker by drawing the line directly in the mouse move handler instead of invalidating the window and letting the OnDraw do it later.</p> <p>The invalidation is the key. You removed the drawing from OnMouseMove, so the line won't get drawn there. But there's nothing to tell Windows that the window contents are now out of date (invalid), and thus it doesn't get a WM_PAINT message, and the OnDraw doesn't get called. (Later, when you do something like resize or maximize the window, that <em>does</em> invalidate it, and the OnDraw is called and the line suddenly appears.)</p> <p>If you want to remove the drawing from OnMouseMove, you'll have to replace it with an InvalidateRect call. That will tell Windows that the window needs to be redrawn.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload