Changing the default button

How can I change the default button of a dialog.

I have tried to change the default button with the following code (where the button B1 is predefined to be the default button):
  UINT bs = m_B1.GetButtonStyle();
  m_B1.SetButtonStyle(bs & !BS_DEFPUSHBUTTON);
  bs = m_B2.GetButtonStyle();
  m_B2.SetButtonStyle(bs | BS_DEFPUSHBUTTON);
But, when I press the tab key to go to the next item in the dialog, the previous default button (B1) shows up again (together with the new default button (B2)). And when the enter key is pressed, it is the old default button's code that is called.
  What am I doing wrong here?
Brian_HPAsked:
Who is Participating?
 
ZoppoConnect With a Mentor Commented:
Hi Brian_HP,

See MSDN article ID: Q67655 for how to do it ...

hope that helps,

ZOPPO
0
 
ZoppoCommented:
You can also use CDialog::SetDefID() instead of sending a DM_SETDEFID message...
0
 
Brian_HPAuthor Commented:
Wher do I find "MSDN article ID: Q67655"?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
ZoppoCommented:
If you have MSDN CD's installed you can just do a full text search for 'Q67655'

or you can find it in MSDN Online at http://support.microsoft.com/support/kb/articles/Q67/6/55.ASP

ZOPPO
0
 
Brian_HPAuthor Commented:
Wher do I find "MSDN article ID: Q67655"?
0
 
Brian_HPAuthor Commented:
Thanks!

I thought I have tried that, but apparently I have not. Now it works :)
0
All Courses

From novice to tech pro — start learning today.