山寨:不是最好的,是最适合我们的!欢迎体验山寨 中文版MSDN

Blog @ Blog

当华美的叶片落尽,生命的脉络才历历可见。 -- 聂鲁达

常用链接

统计

积分与排名

BBS

Blog

Web

最新评论

三方法改变每个标签页标题

概要

CPropertySheet 的选项卡中显示文本是通常取自的对话框模板资源中每个 CPropertyPage 标题。 还有一些其他方法, 可被用来选择对于每一页标题

您可用来选择以下三方法改变每个标签页标题

1、构造 CPropertyPage 函数具有 UINT nIDCaption 参数可用于指定 ID 字符串资源。 默认值为 0 (表示要使用对话框模板标题) 但可标识任何有效字符串资源。
2、CPropertyPage 有称为 m_psp, 是 PROPSHEETPAGE 结构成员。 您可以设置此结构的 dwFlags 元素和 PSP_USETITLE pszTitle 指向字符串将用作标题只能使用此方法之前调用 Create() DoModal()
3.    如果要更改标签中文本, 表创建后可以调用 PropertySheet::GetTabControl() 以获取 CTabCtrl 指针。 然后可以填写 TC_ITEM 结构, 并使用 CTabCtrl 指针, 调用 CTabCtrl::SetItem() 以设置文本对每个选项卡。
示例代码
/* 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;
}

posted on 2008-12-25 16:08 isabc 阅读(1372) 评论(0)  编辑 收藏 引用 所属分类: VC Function


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


广告信息(免费广告联系)

中文版MSDN:
欢迎体验