Change Name of Property Page in Property Sheet?

I have a Property Sheet that contains a Property Page.
I want to override the name of the Page in the Sheet.
Currently it grabs the default name from the dialog resource.
I tried a SetWindowText() call in my OnInitDialog of
the Page, but this does not work.
However, the same code does work if the Page is a
dialog by itself (ie: not in a Sheet).

Does anybody know how to do this?

Who is Participating?
I use code like:
  m_cMyPg.m_psp.pszTitle= "&New Title";
  m_cMyPg.m_psp.dwFlags |= PSP_USETITLE;

before I call cSheet.DoModal();

>>However, I need a way to do this from the Page class,
>>since our Sheet class is generic and is designed to hold
>>different arrangements of pages.

You could do it in the CPropertyPage-derived class's ctor or whereever else you instantiate the object.  It won't work after the sheet has been created.

-- Dan
You can try the PSM_GETTABCONTROL message to get the tab control handle, then TCM_SETITEM to set the item text.
bwilhelmAuthor Commented:
Thanks for the tip.
I tried it and it works great as long as I call it from within the Sheet's OnInitDialog().
However, I need a way to do this from the Page class,
since our Sheet class is generic and is designed to hold different
arrangements of pages.

Likewise I was not able to this at a higher level, where the Sheet
is created and pages are added to it.  This is because the TabControl
is not a valid window handle until DoModal() is called, and by then it's
too late to change the string.

Do you have any other suggestions?
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

// this example to set caption for tab #1 in property sheet
#define TAB_INDEX 1

void CFindSheet::SetTabCaption()
 CTabCtrl* pTab = GetTabControl();
 TC_ITEM ti;
 char szText[100];
 ti.mask = TCIF_TEXT;
 ti.pszText = szText;
 ti.cchTextMax = 100;
 VERIFY(pTab->GetItem(TAB_INDEX, &ti));

 strcpy(szText, "Your tab caption");
 VERIFY(pTab->SetItem(TAB_INDEX, &ti));

then call SetTabCaption on CFindSheet::OnInitDialog()
hi bwilhelm,
Are you still following this question?  Are you interested in another approach?

-- Dan
bwilhelmAuthor Commented:
I worked around this problem by making a non-generic sheet
and implementing the TCM_SETITEM calls.

However, I am still interested in any alternate solutions that
do not involve changing the sheet.
bwilhelmAuthor Commented:
Exactly what I was looking for.  Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.