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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi Brian_HP,

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

hope that helps,

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.