我做了一个属性页,用addpage添加了该属性页的8个对象到pagesheet中,但是标题都是一样的,我现在想更改每一个属性页的标题,该怎么改?谢谢:)

解决方案 »

  1.   

    覆盖每个属性页的OnSetActive()方法,其内部调用父类的SetTilte方法,示例如下:BOOL CMyPropertyPage1::OnSetActive() 
    {
      CMyPropertySheet *pMySheet = (CMyPropertySheet *)GetParent();
      pMySheet->SetTitle("Page1-Title");
      return CPropertyPage::OnSetActive();
    }BOOL CMyPropertyPage2::OnSetActive() 
    {
      CMyPropertySheet *pMySheet = (CMyPropertySheet *)GetParent();
      pMySheet->SetTitle("Page2-Title");
      return CPropertyPage::OnSetActive();
    }请用你自己的CXXXSheet、CXXXPage1、CXXXPage2...来替换示例程序中的相应代码
      

  2.   

    在你的page中:CPropertySheet* pSheet = GetParent();
    CTabCtrl* pTab = pSheet->GetTabControl();
    TCITEM tcItem;
    CString pszString;
    int nSel = pTab->GetCurSel();tcItem.mask = TCIF_TEXT;
    tcItem.pszText = "wwwwww";
    pTab->SetItem(nSel, &tcItem);
      

  3.   

    CPropertySheet *p = (CPropertySheet *)GetParent();
     CTabCtrl *t = p->GetTabControl();
     TCITEM item; // set a mask to tell it to get the text for the item
     item.mask = TCIF_TEXT;
     t->GetItem(2,&item);
     item.pszText = "Tom";
     // set the new text in the control
     t->SetItem(2, &item);
      

  4.   

    抱歉,我的上一回答对于你的问题理解不够准确,改正答案如下:1、对CMyPropertySheet类添加一成员函数
    声明
    public:
      void SetPageTitle(int nTabIndex, CString strTitle);
    实现
    void CMyPropertySheet::SetPageTitle(int nTabIndex, CString strTitle)
    {
      CTabCtrl* pTab = GetTabControl();
      ASSERT (pTab);
      TC_ITEM ti;
      char szText[1024];
      ti.mask = TCIF_TEXT;
      ti.pszText = szText;
      ti.cchTextMax = 100;
      VERIFY (pTab->GetItem (nTabIndex, &ti));
      strcpy(szText, strTitle.Left(1023));
      VERIFY (pTab->SetItem (nTabIndex, &ti));
    }2、覆盖PropertySheet类的OnInitDialog
    BOOL CMyPropertySheet::OnInitDialog() 
    {
      BOOL bResult = CPropertySheet::OnInitDialog();
      SetPageTitle(0,"Page One");
      SetPageTitle(1,"Page Two");
      SetPageTitle(2,"Page Three");
      SetPageTitle(3,"Page Four");
      //我在构造函数中向测试程序中追加了四个属性页
        //你根据实现情况适当调用SetPageTitle(...,...);
      return bResult;
    }