Programming Microsoft Windows with C#

Chapter 8 Programs Don't Require NativeWindow Class

Beginning at the bottom of page 323 of my book Programming Windows with C#, I discuss how writing effective mouse tracking code is hampered by the lack of a Window Forms event corresponding to the Win32 message WM_CAPTURECHANGED. This message occurs when a window that has captured the mouse loses the mouse capture.

As a solution, I show how to process Win32 messages through the WndProc method of the NativeWindow class. However, I have recently discovered that Control (and all classes descended from Control, such as Form) also implement a WndProc method, making use of the NativeWindow class unnecessary for this purpose.

A revised version of the CaptureLoss.cs [rename file after download] program (page 324) overrides the WndProc method to process WM_CAPTURECHANGED messages. The CaptureLossWindow class is no longer required in this file.

Similarly, a revised version of the EvenBetterBlockOut.cs [rename file after download] program (page 328) also overrides the WndProc method to process WM_CAPTURECHANGED messages. The CaptureLossNotifyWindow.cs file (page 327) is no longer required for the revised EvenBetterBlockOut program, and the entire discussion of interfaces (beginning on page 326) can be skipped unless the reader desires to learn something about interfaces.

© Charles Petzold, 2002
cp@charlespetzold.com
This page last updated March, 2002