1 Create Window
The first step to Graphics programming is to create a Window. Some keynotes on window creation:
1.1 Use Template
Start from the template provided by Visual Studio
1.2 Get module instance
Although hInstance
is passed in in WinMain
, it’s better not to pass the hInstance
around. Instead, use GetModuleHandle
to get handle to module instance;
hInstance = GetModuleHandle(nullptr);
1.3 Register window class
When filling out WNDCLASSEX
, two fields are required.
lpszClassName
&& lpfnWndProc
are the only MUST for WNDCLASSEX
.
Leave the other fields as in the template.
1.4 ShowMessage with mShowCmd SW_SHOWDEFAULT
Avoid use 0 as mShowCmd
, since 0 meas SW_HIDE
.
1.5 Destroy window
PostQuitMessage
on WM_DESTROY
, and catch WM_QUIT
in main loop.