首页 > 学院 > 开发设计 > 正文

Create Window

2019-11-10 19:08:15
字体:
来源:转载
供稿:网友

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.


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表