MFC Practice Notes Creation Wizard page __MFC study diary

Source: Internet
Author: User

The creation of the MFC Wizard page is based on two base classes: CPropertyPage (Property Page Class), CPropertySheet (Property group Class).

The dialog box for each page in the wizard inherits from the property page class, and the management of all dialogs is inherited from the attribute group class. The creation of the property page class is the Inheritance Selection property page class for the new class when the dialog box is created.

For an attribute group class, you inherit the property group class when you create a new MFC class in the solution after the property page class is created.

Property page in the Properties of the dialog box: The Style property selects "Child" in the Drop-down list, and the border property selects "Thin" in the Drop-down list. (The specific principle is not yet understood). Then delete the confirmation and Cancel buttons (not used).

In the first property page, there should be a "next" button where to add it. As mentioned in the CPropertyPage function of the previous class, the OnSetActive function is used to process the message that the property page is switched to the currently active page, so we can make the relevant settings in the OnSetActive function.

How do you overload the OnSetActive function? We can find the "csummandpage" node in "Class View", right-click the right-click menu, select "Properties", and then VS2010 the right panel to display a list of properties for the dialog box, and a tip on the toolbar of the property list is " Overrides button, press it, the list below lists the overloaded function, find "onsetactive", point to the right of the blank list items appear down arrow, and then click the arrow appears below the "<add>onsetactive" option, Selecting it automatically adds the function onsetactive to the Csummandpage class.

       All we need to do is add the relevant code to the OnSetActive function body to implement the "next" button. The new function body is as follows: C + + code bool csummandpage::onsetactive ()    {       //  todo: add your specialized code here and/or call the base  class           //  Get the parent window, which is the property sheet CPropertySheet class         CPropertySheet* psheet =  (cpropertysheet*)  getparent ();        //  Settings Property sheet only "Next" button         psheet- >setwizardbuttons (Pswizb_next);           return cpropertypage::onsetactive ();   }  

As above the steps for overloading the onsetactive () function, cpropertysheet* Psheet = (cpropertysheet*) getparent (); Setting the property sheet only the Next button



Psheet->setwizardbuttons (Pswizb_next);

These are the function calls to add the Next button in the wizard box. To use the Finish button in the Last wizard box, invoke the following statement:

Psheet->setfinishtext (_t ("complete"));

You can also overload the Onwizardfinish function to respond to the action after clicking the Finish button.

Property Group Class

After the property page operation is complete, you need to establish an attribute group class. To handle all the property pages. In the following ways:

Right-click on the root node "addition" in the Solution Explorer view, select Add->class in the right-click menu, eject the "Add Class" dialog box, then select "MFC Class" in the middle area, and click "Add" button, Pop-up Another Class wizard dialog box, set class name for Caddsheet,base class select "CPropertySheet", click "Finish" button, so that the property sheet class is built.

After you have created the attribute group class, include the header file for the property page class, and then create a new property Page object. and add the property page to the property sheet in the constructor.   There are two constructors in the property sheet (unexplained) and you need to add the following statement://Add three property pages to the property sheet addpage (&m_summandpage);        M_summandpage is the property Page Object AddPage (&m_addendpage); AddPage (&m_addpage);

Once the operation is complete, you need a function to respond to the Create wizard. You can then create a new button function that adds a response statement to the function, as follows:

Create a property sheet object Caddsheet sheet (_t ("")); The Set Properties dialog box is sheet for the wizard dialog box.        SetWizardMode (); Open the Modal Wizard dialog box sheet. DoModal ();
The results of the operation are shown below:

Summed up a wave: 1, in the forum, some netizens mentioned the order of the property pages, the basic reason is that the constructor in the property table is not added in the order, be sure to follow the normal pop-up order to add. 2. When you add the Next button in the property page, you only need to add it to the OnSetActive function in the first property page, and the rest will have the next step.             Even if there is no overloaded onsetactive function. 3, refueling. Mody.

-----------------------------------------------------------------End----------------------------------------------------- ---

If not add://Set Properties dialog Box for Wizard dialog Sheet.    SetWizardMode (); The result of this statement is:



The wizard is displayed in the form. ---------------------------------------------------------------------------------------End----------------------------- -------------------------------

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.