永发信息网

CMFCPropertySheet AddPage时怎么修改标签的名称

答案:1  悬赏:40  手机版
解决时间 2021-02-02 09:36
CMyPropertyPage *m_Page=new CMyPropertyPage();
AddPage(m_Page);
如何修改m_Page那个标签的名称,
或者可以告诉我如何修改m_Page的caption
setwindowtext已经试过了 报错
最佳答案
Three Methods You Can Use to Select the Caption for Each Page

1. The CPropertyPage constructor has a UINT nIDCaption parameter that can be used to specify a string resource ID. The default is 0 (indicates to use the dialog template caption) but can be any valid string resource ID.
2. The CPropertyPage has a member called m_psp that is a PROPSHEETPAGE structure. You can set this structure's dwFlags element to PSP_USETITLE and pszTitle to a string that will be used as the title. This method can only be used before the call to Create() or DoModal().
3. If you want to change the text in the tabs after the sheet has been created, you can call PropertySheet::GetTabControl() to get a CTabCtrl pointer. You can then fill in a TC_ITEM structure, and using the CTabCtrl pointer, call CTabCtrl::SetItem() to set the text for each tab.

Sample Code:



// 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;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
白云公园的票价是多少?里面有什么玩的?
颖馨美容美体连锁机构(厦大店)地址在什么地方
百度云: 万箭穿心 (12年王竞导演) 天狗(0
珠江夜游交通,如何到达珠江夜游
注眼的意思是什么啊?知道的请说下!
颖馨美容美体连锁机构(会展店)地址在哪,我要
julia is twelve对twelve提问
“可是当时没有考位” 英语怎么说如题
梦幻西游可以跨服购买2008区的东西吗
粉连纸的意思是什么啊?知道的请说下!
46个百分之一组成的数是多少
E调箫筒音是几?
请问包间(或雅座)如何翻译?
颖馨美容美体连锁机构(大唐店)地址在哪,我要
行测资料分析部分主要考什么啊?
推荐资讯
【数学】计算:42/6= 4422/66= 444222/666=
丽人美容美发沙龙地址在什么地方,我要处理点
整数多还是小数多
玩游戏最好的安卓系统是多少,什么版本,几点
丰田RAV4(2.4L) 和三菱OUTLANDER-EX(3.0L
MATLAB运用优化工具解决问题时,怎么定义多元
内向的女孩子怎么搞定她~~能搞定算你厉害
请问,我这个月有希望吗,我2月2号晚上测的是PL
老鼠爱吃大米吗?
为蛇画足的意思是什么啊?知道的请说下!
什么歌英文唱起来是沙乐乐乐沙乐乐乐沙乐乐乐
她妈妈去哪了?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?