Dynamically Setting Tab Title on Propertysheet
-
Hi everyone. I have a dialog with a propertysheet with a tab control style. The propertysheet has 5 propertypages, all of the same class. I want each tab to have a different title on it, eg. "One", "Two", etc. Since they are all of the same class, I can't set the title statically. In the propertypage's OnInitDialog() I try to set the title, but it won't change the title on the tab. Is there a way to set the tab titles in the propertypage's OnInitDialog()? I could create 5 different dialog classes for each propertypage and could set the title statically, but that would be wasteful. I use the code below. It doesn't set the title. It also crashes when the program is in release mode, which I can't understand. Thanks for any help!
BOOL CDlgMyDialog::OnInitDialog() { CDialog::OnInitDialog(); //... // m_ppgMyPropPages is an array of m_ppgMyPropPage for(i = 0; i < 5; ++i) { m_ppgMyPropPages[i].SetMode(i); m_ppsMyPropSheet.AddPage(&m_ppgMyPropPage[i]); } // create the sheet m_ppsMyPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0); m_ppsMyPropSheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT); m_ppsMyPropSheet.ModifyStyle(0, WS_TABSTOP); CRect rcSheet; GetDlgItem(IDC_PPS_MAIN)->GetWindowRect(&rcSheet); ScreenToClient(&rcSheet); m_ppsMyPropSheet.SetWindowPos(NULL, rcSheet.left- 7, rcSheet.top - 7, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //... } BOOL CPpgMyPropPage::OnInitDialog() { CPropertyPage::OnInitDialog(); if(m_iMode == 0) SetWindowText("One"); if(m_iMode == 1) SetWindowText("Two"); if(m_iMode == 2) SetWindowText("Three"); if(m_iMode == 3) SetWindowText.SetWindowText("Four"); if(m_iMode == 4) SetWindowText.SetWindowText("Five"); //.... }
-
Hi everyone. I have a dialog with a propertysheet with a tab control style. The propertysheet has 5 propertypages, all of the same class. I want each tab to have a different title on it, eg. "One", "Two", etc. Since they are all of the same class, I can't set the title statically. In the propertypage's OnInitDialog() I try to set the title, but it won't change the title on the tab. Is there a way to set the tab titles in the propertypage's OnInitDialog()? I could create 5 different dialog classes for each propertypage and could set the title statically, but that would be wasteful. I use the code below. It doesn't set the title. It also crashes when the program is in release mode, which I can't understand. Thanks for any help!
BOOL CDlgMyDialog::OnInitDialog() { CDialog::OnInitDialog(); //... // m_ppgMyPropPages is an array of m_ppgMyPropPage for(i = 0; i < 5; ++i) { m_ppgMyPropPages[i].SetMode(i); m_ppsMyPropSheet.AddPage(&m_ppgMyPropPage[i]); } // create the sheet m_ppsMyPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0); m_ppsMyPropSheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT); m_ppsMyPropSheet.ModifyStyle(0, WS_TABSTOP); CRect rcSheet; GetDlgItem(IDC_PPS_MAIN)->GetWindowRect(&rcSheet); ScreenToClient(&rcSheet); m_ppsMyPropSheet.SetWindowPos(NULL, rcSheet.left- 7, rcSheet.top - 7, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //... } BOOL CPpgMyPropPage::OnInitDialog() { CPropertyPage::OnInitDialog(); if(m_iMode == 0) SetWindowText("One"); if(m_iMode == 1) SetWindowText("Two"); if(m_iMode == 2) SetWindowText("Three"); if(m_iMode == 3) SetWindowText.SetWindowText("Four"); if(m_iMode == 4) SetWindowText.SetWindowText("Five"); //.... }
Take a look at this... in the Constructor of the property sheet...
this->AddPage(&this->m_PPDlgParametritzacioDirectaEixos);
this->m_PPDlgParametritzacioDirectaEixos.m_psp.dwFlags |= PSP_USETITLE;
this->m_PPDlgParametritzacioDirectaEixos.m_psp.pszTitle = "Ejes";Hope this helps...
-
Hi everyone. I have a dialog with a propertysheet with a tab control style. The propertysheet has 5 propertypages, all of the same class. I want each tab to have a different title on it, eg. "One", "Two", etc. Since they are all of the same class, I can't set the title statically. In the propertypage's OnInitDialog() I try to set the title, but it won't change the title on the tab. Is there a way to set the tab titles in the propertypage's OnInitDialog()? I could create 5 different dialog classes for each propertypage and could set the title statically, but that would be wasteful. I use the code below. It doesn't set the title. It also crashes when the program is in release mode, which I can't understand. Thanks for any help!
BOOL CDlgMyDialog::OnInitDialog() { CDialog::OnInitDialog(); //... // m_ppgMyPropPages is an array of m_ppgMyPropPage for(i = 0; i < 5; ++i) { m_ppgMyPropPages[i].SetMode(i); m_ppsMyPropSheet.AddPage(&m_ppgMyPropPage[i]); } // create the sheet m_ppsMyPropSheet.Create(this, WS_CHILD | WS_VISIBLE, 0); m_ppsMyPropSheet.ModifyStyleEx(0, WS_EX_CONTROLPARENT); m_ppsMyPropSheet.ModifyStyle(0, WS_TABSTOP); CRect rcSheet; GetDlgItem(IDC_PPS_MAIN)->GetWindowRect(&rcSheet); ScreenToClient(&rcSheet); m_ppsMyPropSheet.SetWindowPos(NULL, rcSheet.left- 7, rcSheet.top - 7, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //... } BOOL CPpgMyPropPage::OnInitDialog() { CPropertyPage::OnInitDialog(); if(m_iMode == 0) SetWindowText("One"); if(m_iMode == 1) SetWindowText("Two"); if(m_iMode == 2) SetWindowText("Three"); if(m_iMode == 3) SetWindowText.SetWindowText("Four"); if(m_iMode == 4) SetWindowText.SetWindowText("Five"); //.... }
Just Have a Look at the http://www.codeguru.com/forum/printthread.php?threadid=224993