Windows Vista for developers -- Part 1: aero wizard

Source: Internet
Author: User

 

Author: Kenny Kerr

Translation: dflying Chen

Original article: http://weblogs.asp.net/kennykerr/archive/2006/07/12/Windows-Vista-for-Developers-_1320_-Part-1-_1320_-Aero-Wizards.aspx

For more information, see Windows Vista for developers.

 

The aero wizard represents the highest level of development of the wizard interface first introduced by Windows 95 operating systems. It brings a new idea to the common wizard interface, and can better grasp the user's sight. In the first part of the Windows Vista for developers series, I will demonstrate how to use the leastCodeUpdate a traditional Wizard to the latest aero interface.

 

Property sheet)

Recall that the Wizard is just a seriesPropsheetheaderStructure defined attribute list, andPropertysheetFunction implementation. TheCpropertysheetimplThe class template has generated most ofPropertysheetFunction Code. Next, let's start with a simple property ticket and "Upgrade" it into a brand new areo Wizard:

 
ClassSamplewizard:
PublicCpropertysheetimpl <samplewizard>
 
{
 
Public:
 
Begin_msg_map (samplewizard)
 
Chain_msg_map (_ super)
 
End_msg_map ()
 
Samplewizard ():
 
Cpropertysheetimpl <samplewizard> (ids_title)
 
{
 
Verify (addpage (m_page ));
 
}
 
Private:
 
Samplepage m_page;
 
};

TheSamplewizardClass inherits fromCpropertysheetimplClass template automatically obtains many functions provided by the base class. Message map simply transmits messages to the base class. The constructor calls the accumulated constructor to set the title bar of the wizard and useCpropertysheetimplOfAddpageMethod to add a simple page.SamplepageThe class is defined as follows:

ClassSamplepage:
 
PublicCpropertypageimpl <samplepage>
 
{
 
Public:
 
Begin_msg_map (samplepage)
 
Chain_msg_map (_ super)
 
End_msg_map ()
 
Enum{IDD = idd_sample_page };
 
};

SamplepageClass inherited fromCpropertypageimplClass template, which provides most of the features required by the property page.SamplepageThe message map of is also simple to pass the message to the base class. We also need to set the base classIDD(EnumType), so that it can be used to filter the dialog box resources on the property page.

At this time, we can use the following code to create and display a modal attribute list:

 
Samplewizard;
 
Samplewizard. domodal ();

The first line createsSamplewizardObject and its multiple base classes, one of which is to generate a callPropertysheetThe struct required by the function. The second line of samplewizardDomodalMethod (inherited fromCpropertysheetimplClass template) is responsible for callingPropertysheetFunction. The result is that we see a simple property ticket as follows:

 

Classic wizards)

If you want to change the property sheet to a classic style wizard, you only needSamplewizardAdd the following statement to the constructor:

 
M_psh.dwflags | = psh_wizard97;

The above line of code willPsh_wizard97Flag andPropsheetheaderThe existing tags in the structure are combined. Because the wizard interface also contains an additional title area, we need to modifySamplepageClass to add a title text:

 
ClassSamplepage:
 
PublicCpropertypageimpl <samplepage>
 
{
 
Public:
Begin_msg_map (samplepage)
 
Chain_msg_map (_ super)
 
End_msg_map ()
 
Enum{IDD = idd_blank_page };
 
Samplepage ()
 
{
 
Verify (m_title.loadstring (ids_page_title ));
 
Setheadertitle (m_title );
 
}
 
Private:
 
Cstring m_title;
 
 
 
};

SamplepageThe usage of constructors is inherited fromCpropertypageimplOfSetheadertitleTo set the title area. Note pagePropsheetpageThe structure retains the pointer of the string, so the lifetime of the string must exceed the constructor.

After a simple modification, the results are very different:

As you can see, the text that appears on the tab appears in the title bar of the window.

 

Aero wizard)

Now you only needSamplewizardIn the constructorPsh_wizard97ReplacePsh_aerowizardTo see the new Aero wizard interface:

As you can see, the title of the window is returned, but the text of the dialog box that was originally displayed on the attribute Sheet tab is missing.

 

New message)

The aero wizard also provides some new messages for us to better control the controls in the Wizard.

Psm_showwizbuttonsA message is used to display or hide standard buttons in the Wizard.Propsheet_showwizbuttonsMacros can help you send this message easily. Although it is not so intuitive to use, it is not difficult to grasp it once it is used.Propsheet_showwizbuttonsAlthough it is a macro, we can think of it as a function:

 
VoidPropsheet_showwizbuttons (hwnd handle,
 
DWORD buttons,
 
DWORD mask );

HandleThe parameter is used to identify instances in the Wizard window,ButtonsThe parameter is used to specify the buttons to be displayed,MaskThe parameter is used to specify which buttons the Macro will act on. If the tag of a button appears at the same timeButtonsAndMaskParameter, the button is displayed. If a button appears onlyMaskParameter, the button is hidden. We can use the following button Tag:

    1. Pswizb_back
    2. Pswizb_next
    3. Pswizb_finish
    4. Pswizb_cancel

For example, the following code shows the next button and hides the back button:

 
Propsheet_showwizbuttons (handle,
 
Pswizb_next,
 
Pswizb_back | pswizb_next );

Psm_enablewizbuttonsA message is used to enable or disable a standard button.Propsheet_enablewizbuttonsMacros can help you send this message simply:

 
VoidPropsheet_enablewizbuttons (hwnd handle,
 
DWORD buttons,
DWORD mask );

The macro processing method is similarPsm_showwizbuttonsSame --ButtonsThe parameter is used to specify which buttons will be enabled/disabled,MaskThe parameter is used to specify which buttons the Macro will act on. For example, the following code enables the next button and disables the back button:

 
Propsheet_enablewizbuttons (handle,
 
Pswizb_next,
 
Pswizb_back | pswizb_next );

Psm_setbuttontextThe message is used to modify the text on the next, finish, and cancel buttons.Propsheet_setbuttontextMacros can help you send this message simply:

 
VoidPropsheet_setbuttontext (hwnd handle,
 
DWORD button,
 
Pcwstr text );

 

ExampleProgram

To make it easier for you to experience the various enhancements provided by the aero Wizard, I created a simple wizard interface where you can download: http://www.kennyandkarin.com/kenny/vista/aerowizardsample.zip

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.