Game Development Reference
In-Depth Information
y —The y position at the top-left corner of the window relative to
the screen
nWidth —The width of the window in pixels
nHeight —The height of the window in pixels
hWndParent —Handle to a window that is to be the parent of this
window. Our window has no relationship with any other windows;
therefore we set this value to 0.
hMenu —A handle to a menu. Hello World has no menu and speci-
fies 0 for this argument.
hInstance —Handle to the application with which the window
will be associated.
lpParam —A pointer to user-defined data
Note: When we specify the (x, y) coordinates of the window's posi-
tion, they are relative to the upper-left corner of the screen. Also, the
positive x-axis runs to the right as usual, but the positive y-axis runs
downward. Figure 4 shows this coordinate system, which is called
screen coordinates or screen space .
Figure 4: Screen space
CreateWindow returns a handle to the window that it creates (an
HWND ). If the creation failed, the handle will have the value of 0.
Remember that the handle is a way to refer to the window, which is
managed by Windows. Many of the API calls require an HWND so that
they know what window to act on.
The last two function calls in the InitWindowsApp function have
to do with displaying the window. First we call ShowWindow and pass
in the handle of our newly created window so that Windows knows
what window to show. We also pass in an integer value that defines how
the window is to be initially shown (minimized, maximized, etc.). This
value should be nShowCmd , which is an argument of WinMain . You can
hardcode this value in, but it is not recommended. After showing the
window, we should refresh it. UpdateWindow does this; it takes one
argument that is a handle to the window we wish to update.
::ShowWindow(MainWindowHandle, show);
::UpdateWindow(MainWindowHandle);
Search WWH ::




Custom Search