用了个CTabCtrl, 如何重命名该控件上当前选中的Tab页的标题?
(就像Excel中右键后重命名Sheet那样)

解决方案 »

  1.   

    同问同问
    这个问题搞了好久了,还是没有找到可以解决的办法每次用GetItem()获得Item之后,从所获得的Item中获取字符串总是报错请高手指点
      

  2.   

    Sample Code
    /* Compile options needed:  Default
    */// CMySheet is derived from CPropertySheet.
    // CPage1 is derived from CPropertyPage.// METHOD ONE ======================================================
    // passing the string ID to the constructor. ClassWizard does not
    // generate a constructor that takes the caption ID as a parameter,
    // so it may be necessary to modify the CPage1's constructor
    class CPage1 : public CPropertyPage
    {
    // ...public:
        CPage1(UINT nIDCaption = 0);// ...
    };CPage1::CPage1(UINT nIDCaption) :
                  CPropertyPage(CMyPage::IDD, nIDCaption)
    {
        //{{AFX_DATA_INIT(CMyPage)
            // NOTE: the ClassWizard will add member initialization here
        //}}AFX_DATA_INIT
    }// Use the class's constructor to pass the string ID
    CMyView::ShowPropertySheet ()
    {
        m_pSheet = new CMySheet ("Sheet Title");
        ASSERT (m_pSheet);
        m_pPage1 = new CPage1(IDS_MYCAPTION); // id of string resource
        ASSERT (m_pPage1);    m_pSheet->DoModal ();
    }// METHOD TWO ======================================================
    // this shows how to change the title of a CPropertyPage before the
    // call to DoModal()
    CMyView::ShowPropertySheet ()
    {
        m_pSheet = new CMySheet ("Sheet Title");
        ASSERT (m_pSheet);
        m_pPage1 = new CPage1;
        ASSERT (m_pPage1);    m_pPage1->m_psp.dwFlags |= PSP_USETITLE;
        m_pPage1->m_psp.pszTitle = _T("My Caption");    m_pSheet->DoModal ();
    }// METHOD THREE ======================================================
    // This function allows you to pass the index number of a
    // CPropertyPage and a string to set the title to.
    BOOL CMySheet::SetPageTitle (int nPage, LPTSTR pszText)
    {
        CTabCtrl* pTab = GetTabControl();
        ASSERT (pTab);    TC_ITEM ti;
        ti.mask = TCIF_TEXT;
        ti.pszText = pszText;
        VERIFY (pTab->SetItem (nPage, &ti));    return TRUE;
    }
      

  3.   

    TCITEM tcItem={0};
      tcItem.mask = TCIF_TEXT;
    tcItem.pszText = "abc";
    m_wndTabCtrl.SetItem(1,&tcItem);
      

  4.   

    To laiyiling(陌生人 V2.0) :
    这里说的是CTabCtrl,不是CPropertySheet
      

  5.   

    To vcmute(横秋) :
    你这个是指定一个Item,而不是获取某个Item中的标题我们俩问的是如何获取CTabCtrl中的某一个标签的标题