How to Change CPropertyPage's Title
-
How to Change CPropertyPage's Title i wrote the following code, however, the exception occurs in int index = m_sheet.GetPageIndex(this);//make a Exception Thanks
//Main.h CPropertySheet m_sheet; CAboutDlg m_about; //Main.cpp ... m_sheet.AddPage(&m_about); m_sheet.Create(this, WS_CHILD|WS_VISIBLE,WS_EX_CONTROLPARENT); m_sheet.SetWindowPos(NULL, 4, 4,25, 50, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); .... //CAbout.cpp ... m_sheet = GetPrient(); CString szDlgName(_T("test")); TC_ITEM TabCtrlItem; TabCtrlItem.mask = TCIF_TEXT; TabCtrlItem.dwState = TCIS_BUTTONPRESSED; TabCtrlItem.pszText = buf; strcpy(TabCtrlItem.pszText,szDlgName); int index = m_sheet.GetPageIndex(this);//make a Exception // probably the m_sheet is null caused exception, why it is happened m_sheet.GetTabControl()->SetItem(index,&TabCtrlItem); ...
hi -- modified at 1:26 Friday 19th May, 2006 -
How to Change CPropertyPage's Title i wrote the following code, however, the exception occurs in int index = m_sheet.GetPageIndex(this);//make a Exception Thanks
//Main.h CPropertySheet m_sheet; CAboutDlg m_about; //Main.cpp ... m_sheet.AddPage(&m_about); m_sheet.Create(this, WS_CHILD|WS_VISIBLE,WS_EX_CONTROLPARENT); m_sheet.SetWindowPos(NULL, 4, 4,25, 50, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); .... //CAbout.cpp ... m_sheet = GetPrient(); CString szDlgName(_T("test")); TC_ITEM TabCtrlItem; TabCtrlItem.mask = TCIF_TEXT; TabCtrlItem.dwState = TCIS_BUTTONPRESSED; TabCtrlItem.pszText = buf; strcpy(TabCtrlItem.pszText,szDlgName); int index = m_sheet.GetPageIndex(this);//make a Exception // probably the m_sheet is null caused exception, why it is happened m_sheet.GetTabControl()->SetItem(index,&TabCtrlItem); ...
hi -- modified at 1:26 Friday 19th May, 2006 -
How to Change CPropertyPage's Title i wrote the following code, however, the exception occurs in int index = m_sheet.GetPageIndex(this);//make a Exception Thanks
//Main.h CPropertySheet m_sheet; CAboutDlg m_about; //Main.cpp ... m_sheet.AddPage(&m_about); m_sheet.Create(this, WS_CHILD|WS_VISIBLE,WS_EX_CONTROLPARENT); m_sheet.SetWindowPos(NULL, 4, 4,25, 50, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); .... //CAbout.cpp ... m_sheet = GetPrient(); CString szDlgName(_T("test")); TC_ITEM TabCtrlItem; TabCtrlItem.mask = TCIF_TEXT; TabCtrlItem.dwState = TCIS_BUTTONPRESSED; TabCtrlItem.pszText = buf; strcpy(TabCtrlItem.pszText,szDlgName); int index = m_sheet.GetPageIndex(this);//make a Exception // probably the m_sheet is null caused exception, why it is happened m_sheet.GetTabControl()->SetItem(index,&TabCtrlItem); ...
hi -- modified at 1:26 Friday 19th May, 2006It sounds to me that you are calling this function before the window has been created. The exception you get is probably about the hWnd being 0. From where are you calling this? What function?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc.](http://www.soonr.com)
-
You can change the caption of the dialog to cahnge the title. in your case m_about.SetWindowText( "test" ); Regards Anil
-
It sounds to me that you are calling this function before the window has been created. The exception you get is probably about the hWnd being 0. From where are you calling this? What function?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer [SoonR Inc.](http://www.soonr.com)
Thanks i call the function which to change CPropertypage's title,when i click the button in the CPropertypage(others)! Main.h
CPropertySheet m_sheet; CAboutDlg m_about;
Main.cppBOOL COptionDlg::OnInitDialog() { ..... m_sheet.AddPage(&m_about); m_sheet.Create(this, WS_CHILD|WS_VISIBLE,WS_EX_CONTROLPARENT); m_sheet.SetWindowPos(NULL, 4, 4,25, 50, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); .... }
CAbout.cpp //the CAboutDlg was Createdvoid CAboutDlg::UpdateUI() { CPropertySheet* pSheet = (CPropertySheet*)GetParent();//Exception }
hi -
Thanks for you reply! but SetWindowText is not ok!
CPropertySheet* pSheet = (CPropertySheet*)this->GetParent(); //Exception!!!
//addition to the above code COptionDlg* dlg = (COptionDlg*)this->GetParentOwner(); TCHAR buf[MAX_PATH]; TC_ITEM TabCtrlItem;
hi -
Just check if the CAboutDlg is derived from CDialog or CPropertyPage. It should be CPropertyPaeg and must have done CPropertyPage but I am just asking to check it once more. so we can think of other options. Regards Anil