How to get flat button in CPropertySheet(C++V6)?
-
Is there an easy way to get flat button style for standard buttons (OK, cancel...) in a CPropertySheet (in C++ V6)? Thank you in advance, Pierre Couderc Pierre Couderc www.tol.fr
-
Is there an easy way to get flat button style for standard buttons (OK, cancel...) in a CPropertySheet (in C++ V6)? Thank you in advance, Pierre Couderc Pierre Couderc www.tol.fr
-
Thank you very much : you are right that Davide Calbabro CButtonST class is excellent and I use it from years, but I do not see the relation with my problem. My question is how to get an access to OK, cancel button in a CPropertySheet to be able to work on them and pass them in flat mode? Pierre Couderc www.tol.fr
-
Thank you very much : you are right that Davide Calbabro CButtonST class is excellent and I use it from years, but I do not see the relation with my problem. My question is how to get an access to OK, cancel button in a CPropertySheet to be able to work on them and pass them in flat mode? Pierre Couderc www.tol.fr
Oops. I missed the word "standard" in your post :-O sorry! As for those buttons, the only way I can think of is to subclass the buttons with one of the CButtonST buttons. I'm not sure exactly how the class works (I've never used it myself), but I'm fairly sure it would do the job. Try something like this:
CButtonST button;
button.SubclassDlgItem(IDOK, this);in your property sheet - in the WM_CREATE message handler or something similar. You might have to use
EnumChildWindows()
to search for the button with the "OK" text if it doesn't have the IDIDOK
. Similarly for the cancel button. Hope this helps,Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Oops. I missed the word "standard" in your post :-O sorry! As for those buttons, the only way I can think of is to subclass the buttons with one of the CButtonST buttons. I'm not sure exactly how the class works (I've never used it myself), but I'm fairly sure it would do the job. Try something like this:
CButtonST button;
button.SubclassDlgItem(IDOK, this);in your property sheet - in the WM_CREATE message handler or something similar. You might have to use
EnumChildWindows()
to search for the button with the "OK" text if it doesn't have the IDIDOK
. Similarly for the cancel button. Hope this helps,Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Thank you for your ideas. I have tried to override OnInitDialog() but it does not work :
BOOL CMyPropertySheet::OnInitDialog() { BOOL Stat= CPropertySheet::OnInitDialog(); CButton* pButton = (CButton*) this->GetDlgItem(IDCANCEL); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(IDOK); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(IDCLOSE); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(ID_APPLY_NOW); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } return Stat; }
Pierre Couderc www.tol.fr -
Thank you for your ideas. I have tried to override OnInitDialog() but it does not work :
BOOL CMyPropertySheet::OnInitDialog() { BOOL Stat= CPropertySheet::OnInitDialog(); CButton* pButton = (CButton*) this->GetDlgItem(IDCANCEL); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(IDOK); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(IDCLOSE); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } pButton = (CButton*) this->GetDlgItem(ID_APPLY_NOW); if(pButton) { pButton->SetButtonStyle(pButton->GetButtonStyle() | BS_FLAT); pButton->Invalidate(); } return Stat; }
Pierre Couderc www.tol.frThe buttons may not have those IDs. You might have to use
EnumWindows()
orFindWindow
to search for the window with the right text.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
The buttons may not have those IDs. You might have to use
EnumWindows()
orFindWindow
to search for the window with the right text.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Thank you Ryan, - the buttons DO HAVE these IDs : it is harcoded in CPropertySheet. - The good solution is
CButton* pButton = (CButton*) this->GetDlgItem(IDCANCEL); if(pButton) { pButton->ModifyStyle(0,BS_FLAT);}
- see thread microsoft.public.vc.mfc "Desperately trying to get flat buttons in a CPropertySheet" dated 07/02/2006 16:32 Thank you again pierre Pierre Couderc www.tol.fr