|
From: Graeme F. <gr...@dr...> - 2002-09-30 14:32:01
|
To the person who is trying to perform windows programming. I would suggest the following: 1) Windows is an event driven paradigm. So what you need to do is to identify which event you need to trap and place the code there. 2) When you restore a window the O/S sends a paint message to your program. So you need to ensure that your paint message can reconstruct what was on the screen. 3) The same happens if you resize the window (if and only if the window was created WS_HREDRAW and the WS_VREDRAW styles) 4) A mouse moves across the screen and you want to trap some of this information and display it on the screen. The O/S will send a WM_MOUSEMOVE message (pressing buttons will trigger off other messages too) It is here that you need to record the mouse coordinates so that the paint message can display this information on the screen. This could be recorded in a vector (or array) of points. The coordinates are held in the lParam (x = LOWORD(lParam); y = HIWORD(lParam); ) The paint message can then link up all of these points (repetitive LineTo functions or PolyLine if it's an array). BUT and here's is the trap the mouse move will not trigger off a paint message. So you need to trigger it yourself with a call to the InvalidateRect function. Successful windows programming requires you to step back and think which event (or events) you should be using to perform the functionality you require. And be consistent - for example always use the Paint to draw onto the screen. Painting can be done elsewhere but that is normally poor practice leading to potential problems in the future. But most important of all enjoy it. Graeme. |