PropertySheet - possible to change style OK btn?
-
Hi, Thank you for checking out my post. I am writing a simple CPropertySheet (with property pages of course) VC++ 6 Doc/View application, and I want to change the look of the OK or CANCEL buttons. Trouble is that I don't seem to be able to create a control variable of either buttons. The buttons are provided by the framework I am thinking, but does anyone know how to access them? The only interaction I have with the Cancel or OK buttons is to check the return value when dlg.DoModal() returns and that is it. Thanks for any suggestions. Michael
-
Hi, Thank you for checking out my post. I am writing a simple CPropertySheet (with property pages of course) VC++ 6 Doc/View application, and I want to change the look of the OK or CANCEL buttons. Trouble is that I don't seem to be able to create a control variable of either buttons. The buttons are provided by the framework I am thinking, but does anyone know how to access them? The only interaction I have with the Cancel or OK buttons is to check the return value when dlg.DoModal() returns and that is it. Thanks for any suggestions. Michael
In the property sheet class, you can call
GetDlgItem(IDOK)
to get aCWnd*
on the OK button. ChangeIDOK
toIDCANCEL
for the Cancel button. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER -
In the property sheet class, you can call
GetDlgItem(IDOK)
to get aCWnd*
on the OK button. ChangeIDOK
toIDCANCEL
for the Cancel button. --Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIERHi Mike, Thank you so much for replying. I seem to recognize your name...I think you have kindly helped me in the past. Anyway, I did try GetDlgItem(ID_OK) before I posted my question and I couldn't get it to work. It must be the way I did it. It would compile ok but crash on running when doing the check "ASSERT(::IsWindow(m_hWnd));". Here's the code I used within my CPropertySheet class's constructor :- CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { //add each page to the propert sheet this->AddPage(&this->m_prop_page1); //get pointer to OK button so I can alter it CButton * pbutton = (CButton *)this->GetDlgItem(IDOK); } Actually, as I write this I realize that maybe the propertySheet is not a window (and that includes the OK button) until I run "property_sheet_obj.DoModal()", so that might be the problem right there. Do I have to alter the OK button after the DoModal().....I will try that. Thanks Mike and thank you all for any suggestions or confirmation. Michael
-
Hi Mike, Thank you so much for replying. I seem to recognize your name...I think you have kindly helped me in the past. Anyway, I did try GetDlgItem(ID_OK) before I posted my question and I couldn't get it to work. It must be the way I did it. It would compile ok but crash on running when doing the check "ASSERT(::IsWindow(m_hWnd));". Here's the code I used within my CPropertySheet class's constructor :- CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage) { //add each page to the propert sheet this->AddPage(&this->m_prop_page1); //get pointer to OK button so I can alter it CButton * pbutton = (CButton *)this->GetDlgItem(IDOK); } Actually, as I write this I realize that maybe the propertySheet is not a window (and that includes the OK button) until I run "property_sheet_obj.DoModal()", so that might be the problem right there. Do I have to alter the OK button after the DoModal().....I will try that. Thanks Mike and thank you all for any suggestions or confirmation. Michael
No windows are created until after DoModal(), so it might be easiest to do the change in the first page that gets shown:
CPropertySheet* pSheet = (CPropertySheet*) GetParent(); // NOTE: temp CWnd ptr
CWnd* pOKBtn = pSheet->GetDlgItem(IDOK);pOKBtn->SetWindowText ( _T("'Aight") );
--Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER
-
No windows are created until after DoModal(), so it might be easiest to do the change in the first page that gets shown:
CPropertySheet* pSheet = (CPropertySheet*) GetParent(); // NOTE: temp CWnd ptr
CWnd* pOKBtn = pSheet->GetDlgItem(IDOK);pOKBtn->SetWindowText ( _T("'Aight") );
--Mike-- Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber Latest art~!@#2rDFA#@(#*%$Rfa39f3fqwf--= NO CARRIER
Thanks Mike