How the Superclassing Example Works

To illustrate how you use superclassing, I will step through creating a relatively simple application which superclasses two existing window classes. I wrote the code completely in VB. However, I wrote it using Windows API functions. Visual C++ developers might recognize this code to be similar to the standard “hello world” application written in Visual C++.

The example will first superclass the ThunderRt6FormDC class that is used to create VB forms. The new class will be identified by the name NewMainWindowClass. It will have its own window procedure and will use the IDC_UPARROW mouse pointer as its default pointer. Normally, window classes use the IDC_ARROW for their mouse pointer. The IDC_UPARROW mouse pointer is simply an arrow pointer similar to the default mouse pointer, except that it points straight up instead of upward and to the left.

The caption for the first window created from the NewMainWindowClass superclass will be “Main Window”, as Figure 7-4 shows. All subsequent windows created from this class will have the caption “New Window”, as Figure 7-5 shows.

The main window

Figure 7-4. The main window

The new window

Figure 7-5. The new window

In addition to superclassing ThunderRT6FormDC, we’ll also superclass the system-wide BUTTON window class. This is the class that ...

Get Subclassing and Hooking with Visual Basic 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.