Game Development Reference
In-Depth Information
The second statement is an instantiation of a global variable of type
HWND . This stands for “handle to a window.” In Windows programming,
we often use handles to refer to objects maintained internally by Win-
dows. In this sample, we use an HWND to refer to our main application
window maintained by Windows. We need to hold onto the handles of
our windows because many calls to the API require that we pass in the
handle of the window that we want the API call to act on. For example,
the call UpdateWindow takes one argument that is of type HWND that
is used to specify the window to update. If we didn't pass in a handle to
it, the function wouldn't know what window to update.
HWND MainWindowHandle = 0;
The next three lines are function declarations. Briefly, InitWindows-
App creates and initializes our main application window, Run encapsu-
lates the message loop for our application, and WndProc is our main
window's window procedure. We examine these functions in more
detail when we come to the point where they are called.
bool InitWindowsApp(HINSTANCE instanceHandle, int show);
int Run();
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
WinMain
WinMain is the Windows equivalent to the main function in normal
C++ programming. WinMain is prototyped as follows:
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR
lpCmdLine,
int
nCmdShow
);
hInstance —Handle to the current application instance. It serves
as a way of identifying and referring to this application. Remember
that there may be several Windows applications running concur-
rently, so it is useful to be able to refer to each one.
hPrevInstance —Not used in 32-bit Win32 programming and is 0
lpCmdLine —The command line argument string used to run the
program
nCmdShow —Specifies how the application window should be dis-
played. Some common commands that show the window in its cur-
rent size and position, maximized, and minimized, respectively, are
SW_SHOW , SW_SHOWMAXIMIZED , and SW_SHOWMINIMIZED . See
the MSDN library for a complete list of show commands.
Search WWH ::




Custom Search