How to override the default buttons on a properysheet:
What you need to do is override the OnSetDefID in CPropertySheet.
So you would add the following to your message map in your derived class:
And declare OnSetDefID which would look something like this:
//CMG: Override the CPropertySheet default button and replace with own.
LRESULT CTSIDlg::OnSetDefID(WPARAM wParam, LPARAM lParam)
//The current default ID, in case you want to access it:
int nIDOldDef = LOWORD(DefWindowProc(DM_GETDEFID, wParam, lParam));
lReturn = DefWindowProc(DM_SETDEFID, YOUR_ID_HERE, lParam);
Note in the DefWindowProc you can set the default ID for your own control.
One thing I didn’t figure out is how to erase the dark
highlight from the OK button. But the ID you set will also have the dark highlight.
If you were using the Wizard you might do this differently. If you want a really nice piece of code I could send it
later as in Wizard mode the FINISH button and NEXT button would need to be default sometimes. But if you just have a regular PropertySheet
dialog and want to override the default button this will do the job.
Last updated: 22 July 1998