Capturing the Mouse
A window procedure normally receives mouse messages only when the mouse cursor is positioned over the client or nonclient area of the window. A program might need to receive mouse messages when the mouse is outside the window. If so, the program can “capture” the mouse. Don’t worry: it won’t bite.
Blocking Out a Rectangle
To examine why capturing the mouse might be necessary, let’s look at the BLOKOUT1 program shown in Example 7-6. This program may seem functional, but it has a nasty flaw.
Example 7-6. The BLOKOUT1 program.
BLOKOUT1.C /*----------------------------------------- BLOKOUT1.C -- Mouse Button Demo Program (c) Charles Petzold, 1998 -----------------------------------------*/ #include <windows.h> LRESULT CALLBACK WndProc ...
Get Programming Windows®, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.