Click to See Complete Forum and Search --> : Changing Title of propertypage
Wuppinger
September 15th, 1999, 06:03 AM
Changing the title of a propertypage!
How can I change the title of a propertypage during runtime after I've added it already to the propertysheet? Because SetWindowText() doesn't work in my application!
I use VC 5.0!
Thanks a lot for your reply!
Ralph
Oleg Lobach
September 15th, 1999, 06:08 AM
Hi,
try this:
CMyPropSheet::SetPageTitle (int nPage, LPTSTR pszText)
{
CTabCtrl* pTab = GetTabControl();
TC_ITEM ti;
ti.mask = TCIF_TEXT;
ti.pszText = pszText;
pTab->SetItem (nPage, &ti);
}
Hope this helps,
Oleg.
Sandrine
September 15th, 1999, 06:37 AM
You create your CPropertyPage objects ( m_dlgPage1) and CPropertySheet object ( m_dlgPropSheet)
1- Add your page:
/* --- Add the pages --- */
m_dlgPropSheet->AddPage(m_dlgPage1);
2- Change its title
/* --- Add the title --- */
m_dlgPage1->m_psp.pszTitle = _T("My title");
m_dlgPage1->m_psp.dwFlags |= PSP_USETITLE;
Bye
Sandrine
Wuppinger
September 15th, 1999, 08:45 AM
Thanks a lot for your reply!
It works!
have a nice day !
Ralph
Wuppinger
September 15th, 1999, 08:47 AM
Thanks a lot for your reply!
But this suggestion will only work BEFORE you call the AddPage() methode!
have a nice day !
Ralph
Sandrine
September 15th, 1999, 09:12 AM
?????
This is my code ( A part of the OnInitDialogDialog function of the dialog box which contains the property sheet). And It works...
// Property Sheet
/* --- Create the property sheet object --- */
m_dlgPropSheet = new CPropertySheet;
/* --- Create Property Page Object --- */
m_dlgPage1 = new CConvSimulPage;
m_dlgPage2 = new CConvSimulPagebis;
/* --- Add the pages --- */
m_dlgPropSheet->AddPage(m_dlgPage1);
m_dlgPropSheet->AddPage(m_dlgPage2);
/* --- Add the title --- */
m_dlgPage1->m_psp.pszTitle = _T("Solar Array");
m_dlgPage1->m_psp.dwFlags |= PSP_USETITLE;
m_dlgPage2->m_psp.pszTitle = _T("Battery");
m_dlgPage2->m_psp.dwFlags |= PSP_USETITLE;
/* --- Initialization and display the property sheet --- */
m_dlgPropSheet->Create(this, WS_CHILD | WS_VISIBLE, 0 );
m_dlgPropSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
m_dlgPropSheet->ModifyStyle(0,WS_TABSTOP);
CRect rcSheet;
GetDlgItem(IDC_PROPSHEET)->GetWindowRect(&rcSheet);
ScreenToClient(&rcSheet);
.....
Something wrong??
Bye
Sandrine
Wuppinger
September 15th, 1999, 11:49 AM
Thanks for the complete code, but I'm not sure whether the changing of the title will work after the "m_dlgPropSheet->Create()". With other words:
after OnInitDialog() and when your dialog appears
you should be able to change the title by pressing a certain button (for example) in your dialogbox.
I tested the other suggestion and it works in this
way.
Thanks a lot again!
bye
Ralph
January 3rd, 2000, 10:59 AM
I tried Sandrine's method because it looked _much_ simpler. It works fine after the OnCreate of the PropertySheet (though I do use it before the DoModal, that shows the property sheet). The only caveat is that Sandrine's code declares a PropertyPage, but references it as a *pointer* to a PropertyPage. The '->' should be a '.' (period).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.