利用属性页制作选项对话框的方法

其实很容易,一会就做成功了


1)建若干个对话框,每个对话框的属性要设置一下,


算了,还是看MS的这篇文章吧


void CAboutDlg::OnButton1() 
{
// TODO: Add your control notification handler code here
CPropertySheet ps;
MyPage1 pg1;
MyPage2 pg2;
MyPage3 pg3;


ps.AddPage(&pg1);
ps.AddPage(&pg2);
ps.AddPage(&pg3);


ps.SetTitle("Title of property sheet");
ps.DoModal();
}

Using Property Sheets in Your Application

To use a property sheet in your application, complete the following steps:

  1. Create a dialog template resource for each property page. Keep in mind that the user may be switching from one page to another, so lay out each page as consistently as possible.

    The dialog templates for all pages do not have to be the same size. The framework uses the size of the largest page to determine how much space to allocate in the property sheet for the property pages.

    When you create the dialog template resource for a property page, you must specify the following styles in the Dialog Properties property sheet:

    • Set the Caption edit box on the General page to the text you wish to appear in the tab for this page.

    • Set the Style list box on the Styles page to Child.

    • Set the Border list box on the Styles page to Thin.

    • Ensure that the Titlebar check box on the Styles page is selected.

    • Ensure that the Disabled check box on the More Styles page is selected.
  2. Use ClassWizard to create a CPropertyPage-derived class corresponding to each property page dialog template. To do this, choose ClassWizard from the View menu while the focus is on a particular property page dialog box. Choose CPropertyPage as the base class in ClassWizard.

  3. Using ClassWizard, create member variables to hold the values for this property page. The process for adding member variables to a property page is exactly the same as adding member variables to a dialog box, because a property page is a specialized dialog box.

  4. Construct a CPropertySheet object in your source code. Usually, you construct the CPropertySheet object in the handler for the command that displays the property sheet. This object represents the entire property sheet. If you create a modal property sheet with the DoModal function, the framework supplies three command buttons by default: OK, Cancel, and Apply. The framework creates no command buttons for modeless property sheets created with the Create function. You do not need to derive a class from CPropertySheet unless you want to either add other controls (such as a preview window) or display a modeless property sheet. This step is necessary for modeless property sheets because they do not contain any default controls that could be used to close the property sheet.

  5. For each page to be added to the property sheet, do the following:
    • Construct one object for each CPropertyPage-derived class that you created using ClassWizard earlier in this process.

    • Call CPropertySheet::AddPage for each page.

    Typically, the object that creates the CPropertySheet also creates the CPropertyPage objects in this step. However, if you implement a CPropertySheet-derived class, you can embed the CPropertyPage objects in the CPropertySheet object and call AddPage for each page from the CPropertySheet-derived class constructor. AddPage adds the CPropertyPage object to the property sheet’s list of pages but does not actually create the window for that page. Therefore, it is not necessary to wait until creation of the property sheet window to call AddPage; you can call AddPage from the property sheet’s constructor.

  6. Call CPropertySheet::DoModal or Create to display the property sheet. Call DoModal to create a property sheet as a modal dialog box. Call Create to create the property sheet as a modeless dialog box.

  7. Exchange data between property pages and the owner of the property sheet. This is explained in the article Property Sheets: Exchanging Data

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值