我的编译平台是vs2008。
我想创建 一个CPropSheet类来继承CPropertySheet类,然而构造函数怎么写呢?
我添加类后,CPropSheet的构造函数默认为:CPropSheet::CPropSheet(void)
{
}
那么我如何写传入参数呢?好像有一种基类的继承方法,不过我忘了基础不好,请大虾们见谅。另外,我想修改CPropSheet上的按钮,如去掉确定和应用按钮,将取消按钮的文字改为Exit,那怎么实现呢?
(向导的话孙鑫的视频讲了,但普通的属性表单就没说,我在网上搜到也说得不太清楚。)请各位速速请教谢谢。

解决方案 »

  1.   

    1、下面的方式,param是你要传的参数CPropSheet::CPropSheet(void): CPropertySheet(param)
    2、用下面的方式来隐藏按钮或者调整按钮位置,或者修改文字,主要是先找到按钮的指针
    之后再做处理就行了
    至于相关的id可以查一下相关的资料
            CWnd* pWnd = GetDlgItem(IDHELP);
    if ( pWnd && pWnd->GetSafeHwnd() )
    {
    pWnd->ShowWindow(SW_HIDE);
    }
       
      

  2.   

    楼主你可以看下 CPropertySheet类是如何实现的,你可以看下源码,直接研究下,然后再改。。
      

  3.   

    在你的重载CPropertySheet类的OnInitDialog函数中加入如下内容即可
    BOOL CNewPage::OnInitDialog()
    {
    BOOL bResult = CPropertySheet::OnInitDialog(); //SetWizardMode();
    // TODO:  Add your specialized code here
    GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
    GetDlgItem(IDCANCEL)->SetWindowText(_T("Exit")); GetDlgItem(ID_APPLY_NOW)->ShowWindow(SW_HIDE); return bResult;
    }
      

  4.   

    CPropSheet::CPropSheet(void): CPropertySheet(param)
    这样?这样会报错啊
    CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd = NULL,UINT iSelectPage = 0):CPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL,UINT iSelectPage = 0)
    {
    }
      

  5.   

    那构造函数呢?我定义对象想CPropertySheet那样定义不行啊。
      

  6.   


    大哥,你不是吧?
    你看看msdn中CPropertySheet的构造函数是怎样定义的
    你在根据他的定义传你的参数进去啊// 这样应该是可以的
    CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd=NULL,UINT iSelectPage=0)
    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
    {
    }
    CPropertySheet( ); 
    explicit CPropertySheet(
       UINT nIDCaption,
       CWnd* pParentWnd = NULL,
       UINT iSelectPage = 0 
    );
    explicit CPropertySheet(
       LPCTSTR pszCaption,
       CWnd* pParentWnd = NULL,
       UINT iSelectPage = 0 
    );
    CPropertySheet(
       UINT nIDCaption,
       CWnd* pParentWnd,
       UINT iSelectPage,
       HBITMAP hbmWater,
       HPALETTE hpalWater = NULL,
       HBITMAP hbmHeader = NULL 
    );
    CPropertySheet(
       LPCTSTR pszCaption,
       CWnd* pParentWnd,
       UINT iSelectPage,
       HBITMAP hbmWater,
       HPALETTE hpalWater = NULL,
       HBITMAP hbmHeader = NULL 
    );
      

  7.   

    3楼的Allen_zhang 已经讲的很清楚了
      

  8.   

    建议你看下 visual c++ 6 编程宝典 的14章,专门讲属性页的
      

  9.   

    Using Property Sheets in Your Application
    Home |  Overview |  How Do I | SampleTo use a property sheet in your application, complete the following steps: 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. 
    Use ClassWizard to create aCPropertyPage-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.
    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.
    Construct aCPropertySheet 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 theDoModal 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 theCreate 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.
    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.
    CallCPropertySheet::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.CallCPropertySheet::DoModal orCreate 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.
    Exchange data between property pages and the owner of the property sheet. This is explained in the article Property Sheets: Exchanging Data. 
      

  10.   

    在MSDN里面输入:Using Property Sheets  标准操作详细介绍。
      

  11.   

    我的问题基本解决了谢谢各位,特别感谢VisualEleven。