Game Development Reference
In-Depth Information
// destroy the main application window, which is
// identified by MainWindowHandle.
case WM_KEYDOWN:
if( wParam == VK_ESCAPE )
::DestroyWindow(MainWindowHandle);
return 0;
// In the case of a destroy message, then
// send a quit message, which will terminate
// the message loop.
case WM_DESTROY:
::PostQuitMessage(0);
return 0;
}
// Forward any other messages we didn't handle
// above to the default window procedure.
return ::DefWindowProc(windowHandle,
msg,
wParam,
lParam);
}
Figure 3: A screen
shot of the above
program. Note that
the message box
appears when you
press the left mouse
button in the win-
dow's client area.
Explaining Hello World
Let's examine the code from top to bottom, stepping into any function
that gets called along the way. Refer back to the Hello World code list-
ing throughout these subsections.
Includes, Global Variables, and Prototypes
The first thing we do is include the windows.h header file. By including
the windows.h file, we obtain the structures, types, and function decla-
rations needed for using the basic elements of the Win32 API.
#include <windows.h>
Search WWH ::




Custom Search