In the previous article I highlighted the basic structure of the Windows API32 program, do you want to complete your first Windows program? Don't be busy. Let me first introduce you to the API window function, which you can program only if you understand it.
What is a window function? What does it define? The window function defines the response of the application to the different messages received, including the processing of the various possible messages that the application has received, and the collection of Message Processing branch control statements. In general, window functions consist of one or more switch statements. Each case statement corresponds to a message, and when the application receives a message, the corresponding statement within the window function is activated and the corresponding responder module is executed.
Simply put, the window function is the function of the application to process the received message, which contains the application's handling of various potentially useful messages.
The general format of a window function is this:
LRESULT CALLBACK WndProc
( HWND hwnd, //窗口句柄
UNIT message, //代表所处理消息的消息值
WPARAM wParam, //消息的附加参数(1)
LPARAM lParam //消息的附加参数(2)
)
{
... //省略
switch(message) //message为标识消息的消息值
{
case...
...
break;
...
case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return(0);
}
The main content of a window function is a message processing statement, which consists of multiple case statements. You just need to write the appropriate handler segment in the case statement for the message that the window might receive.