Prev Index Next

Blockout 1 and 2

Mouse capture

Mouse capture

Notes: These two programs are meant to show an example of when it would be necessary to capture mouse input (Process all mouse messages even if the mouse is not inside the program's window). The programs have you click the mouse and drag it to create a rectangular outline, when you release the mouse it turns that outline into a filled rectangle. The problem is that in the original program (Top) when you move the mouse out of the window and release the mouse button the program doesn't get this message. Then when you move the mouse back into the window it still thinks the button is pressed and tries to draw the outline which can lead to some strange results. The solution is to capture the mouse when you click in the window to ensure the program gets the message when you release the mouse.

Description: A screenshot of two programs in front of a window containing code. The top window has a white background and contains the outline of an L-shaped polygon. The bottom window has a white background and contains a black rectangle.

Prev Index Next