The Window Class


Imagine for a moment that Windows is written in Visual Basic and that every window you see on the screen is actually a window object of type CWindow. You might create a new window this way:

Dim wndMy As New CWindow
wndMy.Create(“MyClass", “My Window", _
afEnabled Or afVisible Or afOtherStyle, _
x, y, dx, dy, hwndParent, hMenu, hInst, objOther)

After creating the window, you could access its properties as shown here:

With wndMy
.Caption = “My New Window Title"
afStyle = .Style
x = .Point.x
End With

You could also call window methods such as these:

With wndMy
.Move xNew, yNew
If .Enabled Then .MakeActive
End With

Does this look at all familiar? Doesn’t it look like initializing a form? In fact, this imaginary code is a very simplified view of what Visual Basic asks Windows to do when you ask Visual Basic to load a form. It’s also what Visual Basic does when it loads most controls.