Chicken Peck Rice MFC Tutorial Note Four: Dialog box: Create dialog template and Modify dialog box properties

Source: Internet
Author: User

---restore content starts---

This section begins by explaining the application-based knowledge- Creating a dialog box .

dialog box, we should be familiar with, in most of our commonly used software has a dialog box interface, for example, 360 security defender's main interface is actually a dialog box, but it did a lot of art work, it greatly beautify.

There are two major steps in creating a dialog, first, Creating a dialog Resource , which includes creating a new dialog template, setting dialog properties, and adding various controls to the dialog box;

Second, the dialog class is generated , including the new dialog class, the addition of the control variables and the control's message handler functions, and so on.

Here the chickens Peck rice and then create a dialog-based application that implements the function of the addition operation. As follows:

As we can see in the Solution Explorer View , this project has fewer files than a single document application, there are three main classes in Class View:CAboutDlg, Cadditionapp and Cadditiondlg. CAboutDlg is the "about" dialog class for the application, Cadditionapp is a class derived from CWinApp , and Cadditiondlg is the main dialog Class , The main dialog box is the main interface that is displayed after the application is run.

In Resource view, you can see the resource tree for the project addition, expand Addition.rc, with four subkeys:Dialog (dialog box), icon, String Table (string table) and version (versions). then expand the DIALOG entry with the following two dialog template IDs:idd_aboutbox and Idd_addition_dialog, which are "about" The template for the dialog box, which is the template for the main dialog box . An ID is a unique identifier for a resource, essentially an unsigned integer, and the integer value represented by the general ID is defined by the system and we do not need to interfere.

dialog box templates

Visible for the main dialog box, the Create New dialog box template in the first step of the Create dialog box has been automatically completed by the system. If you add a dialog box to create a new dialog template , you need to right-click on the "Dialog" node of the Resource View and select "Insert Dialog" in the right-click menu to generate a new dialog box template and The ID is automatically assigned.

Setting dialog Box Properties

in a ddition on the dialog box template Point Right Key , then select Pro from the right-click menu Perties, then on the right The panel will display List of properties for the dialog box . such as:

1.ID: The dialog ID, which uniquely identifies the dialog resource, can be modified. Here is Idd_addition_dialog, we do not modify it.

2.Caption: dialog box title . The default here is addition, which we'll change to "addition Calculator".

3.Border: Border type . There are four types: None, Thin, resizing, and dialog Frame. We use the default dialog Frame.

4.Maximize: whether to use the Maximize button . We use the default false.

5.Minimize: Whether to use the Minimize button . Likewise we use the default false.

6.Style: dialog box type . There are three types: Overlapped (overlapping window), popup (pop-up window), and child (sub-window). Pop-up windows are more common. We use the default popup type.

7.System Menu: the System menu with the upper-left corner of the title bar , including the move, close, and other menu items. We use the default true.

8.Title Bar: Whether it has a title bar . We use the default true.

9.Font (size): font type and font size . If you modify it to a non-system font, the use system automatically changes to false. The font (Size) is automatically set to the system font if the use system turns false and it is modified to true. Here we use the default system font.

According to the above instructions, we have only modified the title property.

Chicken Peck Rice MFC Tutorial Note Four: Dialog box: Create dialog template and Modify dialog box properties

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.