But wait. When you use BLOWUP1 to block out an image outside its client area, the program briefly displays the image in reverse video and then restores it to normal. BLOWUP1 is apparently writing outside its client area. Can that be so?
It certainly can. This little trick is carried off in BLOWUP1's InvertBlock function. Rather than obtain a device context handle from GetDC, InvertBlock uses CreateDC:
hdc = CreateDC ("DISPLAY", NULL, NULL, NULL) ;
This returns a device context handle for the entire display. Using this device context handle, you can write outside your client area.
InvertBlock uses the GDI PatBlt function (a ”pattern bit-block transfer“) to invert the blocked-out image. BLOWUP1 calls InvertBlock twice in succession. When called the second time, the block is restored to normal. This means that you can see the block briefly only when you move the mouse cursor.
Why do it like this? BLOWUP1 doesn't leave the block in an inverted state because other Windows programs can receive messages between BLOWUP1's WM_MOUSEMOVE messages. (For instance, the Windows CLOCK gets WM_TIMER messages every second.) If BLOWUP1 left the block inverted when it exited its window function, then the program with the altered client area could write over the inverted block. When BLOWUP1 then reinverted the block—that is, returned it to normal—the result would start looking like a mess. Keep considerations like this in mind when you start working with powerful functions like CreateDC. Windows gives you the power to do almost anything, but your programs must share resources such as the display with other programs. Try to exercise a little restraint.