Simple Windows API program structure

xiaoxiao2021-03-06  38

Function part:

1, int WinApi WinMain

Is the main function of WinAPI programs

2, LRESULT CALLBACK WNDPROC

The message handler of the window. Specify this function in the lpfnwndproc attribute of the window class.

Write program sequence part:

1. Create a WNDCLASS structure and set some "initial value" [window attribute]

WNDCLASS WNDCLASS;

Note these two properties:

WNDCLASS.LPFNWNDPROC = WNDPROC;

WNDCLASS.HINSTANCE = Hinstance; // Current instance

2, use registerclass to register the window class and test whether the registration is successful (failure may be the system version is too low).

IF (! registerclass (& wndclass)) {failed}

3, create a window clause HWnd with CREATEWINDOW

4. Use ShowWindow to display the window with HWNDOW in HWND and ICMDSHOW [program (such as minimization, etc.)].

5, UpdateWindow (HWND);

6, handle the message loop [did not understand: (]

While (GetMessage (& MSG, NULL, 0, 0))

{

TranslateMessage (& MSG);

DispatchMessage (& MSG);

}

Return msg.wparam;

转载请注明原文地址:https://www.9cbs.com/read-66285.html

New Post(0)