Primary Windows API C + + language programming (2)

Source: Internet
Author: User
Tags case statement

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.