Inside CWindow
Lets take an inside look at CWindow. This class is undocumented, but it exists, and Windows explorers have mapped out its contents. In their flat-earth ignorance, these pioneers (of whom Matt Pietrek, author of Windows 95 System Secrets, is captain) believe that Windows was written in C, and so they call this hidden data the WND structure. Our more enlightened view is that this block of data is nothing less than the private variables of Visual Basics CWindow class.
And now, revealed for the first time, the secret heart of every window:
Private hWndNext As Long Next sibling window
Private hWndChild As Long First child window
Private hWndParent As Long Parent window
Private hWndOwner As Long Owning window
Private rectWindow As RECT Rectangle of entire window
Private rectClient As RECT Rectangle of client area
Private hQueue As Integer Application message queue
Private hrgnUpdate As Integer Region needing update
Private wndClass As Integer Window class
Private hInstance As Integer Instance handle
Private lplfnWndProc As Long Window procedure
Private afFlags As Long Internal flags
Private afStyle As Long Style flags
Private afStyleExt As Long Extended style flags
Private afMoreFlags As Long More internal flags
Private hMenu As Long Menu used by window
Private hBuffer As Long Buffer for title
Private scrollBar As Integer Scroll bar word
Private hProperties As Integer First window property
Private hWnd16 As Integer The 16-bit window handle
Private pWndLastActive As Long Last active popup window
Private hMenuSystem As Long System menu
Private atomClass As Integer Class name
Private pidAlternate As Long Process ID
Private tidAlternate As Long Thread ID
This is the Microsoft Windows 95 version; Microsoft Windows NT might vary slightly. What can you do with this information? As a practical matter, absolutely nothing. The only way you can change these private variables is through properties and methods of the public interface. In a more abstract sense, however, knowing whats inside helps you understand what the public methods and properties must work with and, thus, what they can and cannot do.
Although Windows is object-oriented in the philosophical sense of hiding data, inheriting attributes, and allowing polymorphic access to objects, its public interface is completely functional. Thus, instead of providing window objects with properties and methods, Windows provides functions that take a window handle argument.
You might like to do things the object-oriented way:
wndMy.Enabled = True
f = wndMy.Enabled
wndMy.Flash True
But in fact you have to call functions:
fOld = EnableWindow(hWnd, True)
f = IsWindowEnabled(hWnd)
FlashWindow hWnd, True
Of course, if youre dealing with Visual Basic windows, the Enable functions dont matter because the form or control representing the window has an Enabled property. If you want to flash the window, however, youll have to do it the Windows Way because flashing a window is an obscure feature not deemed worthy of inclusion in Visual Basic. No problem. All you need is a declaration for FlashWindow so that you can call it like this:
FlashWindow Me.hWnd, True