Map Drawing Tool - Help!

Started by
10 comments, last by SFA 20 years, 5 months ago
quote:Original post by RuneLancer
Just send a WM_PAINT message to your program

A better option is to call .invalidate() on the component that needs redrawing. This means that the redraw event comes in at a suitable time (and may be merged with an already queued repaint event).
Advertisement
Another thing you might want to change is the use of BeginPaint - it is a special function that sets clipping values so you only update the part of the window that needs repainting (when the WM_PAINT message is called). If you want to draw anywhere on the window, you probably want to use GetDC and ReleaseDC instead.

Also, as has been mentioned, you might want to do double buffering to avoid flicker. In order to do that, you need to use CreateCompatibleDC to make a new DC, then CreateCompatableBitmap to make a buffer for it, then SelectObject to tell the compatable DC to use the compatable Bitmap:

HDC memDC = CreateCompatibleDC ( hDC );
HBITMAP memBM = CreateCompatibleBitmap ( hDC );
SelectObject ( memDC, memBM );

Then you can draw into memDC and use BitBlt to copy its image to the window.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement