About RegisterClass and CreateWindow

Source: Internet
Author: User

RegisterClass the function name and its parameters to explain, Chinese meaning is registered window category, as the name implies is registered a window class, and CreateWindow literally means to create a window. Maybe just doing Windows development has a bit of a problem with the two functions and their association.

The role of the RegisterClass function is to inform the system that you want to define a new form type and then record that type into the system, and then you can use CreateWindow to create a form based on this type. Forms based on this type have the same properties, such as background color, cursor, icon, and so on. In MFC, for dialog boxes, the system has already registered the dialog box's own type, so you can use your own dialog class to create modal or non-modal windows without calling RegisterClass.

For a control, the system has registered the dialog box's own type, so you can use CreateWindow to create the control without calling RegisterClass, and the first parameter in CreateWindow It is the member lpszClassName in the WNDCLASS structure that is used by the RegisterClass function.
The difference between a Windows control and a dialog box is that the form procedure for a dialog box is provided by the caller, and the form procedure for the control is defined in the system, and you must subclass the form (so-called subclasses can refer to my previous "subclass and Superclass Differences" article) in order to customize the processing message logic of the control.
In fact, plainly, as early as the C language window programming era, has supported the inheritance, which for the future C + + language implementation laid the foundation. The role of the RegisterClass function is to define a form class, relative to the class concept in C + +, and CreateWindow This function is to define an object based on this type, relative to the concept of an object in C + +.

About RegisterClass and CreateWindow

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.