I was having some trouble with defining the default button in a dialog. It appears that the dialog editor does not properly add the 0x0001 for the default button and puts a 'B' on the end. 0x000B is BS_OWNERDRAW.
The ownerdraw style is needed for color buttons. If you check the "XP compatible" checkmark then it will be a standard button.
Paul.
And upon further investigation it appears that a button with the BS_OWNERDRAW style can't be a default button since the bits confilct in the style (microsoft article). (0xB = 0x1011)
Well it can be but you need to use a function to set it. I will change the source output so when "XP theme compatible" is checked that the button retains its default button setting.
Came up with a better solution. Since dialogs are created by using an internal memory template it is possible to specify the default button even with an owner drawn one. The easiest way to accomplish this was to add another control type constant.
d1.AddControl(CTDEFBUTTON...
The dialog editor now understands this and will chose CTBUTTON or CTDEFBUTTON depending on the properties.
Button controls create dynamically just need to specify the 0x0001 (ABS_DEFAULT) style when creating control. This will maintain backwords compatibility with current code.
Sounds good. I used
const BS_DEFPUSHBUTTON = 1;
which of course is the same value.
All the above work, but as soon as I click into any edit control, the default button changes to CANCEL.
For data entry, I want to be able to click OK when I'm through and not have to use the mouse. How do I keep OK as the default?
Sounds like you have two default buttons.
You have to use the CTDEFBUTTON type for it to work properly and not the BS_DEFBUTTON style
Quote from: Ionic Wizard on March 10, 2006, 12:31:06 PM
Sounds like you have two default buttons.
It does more than sound like itÂÃ, :P
Man, how can a guy stare at code all day long and not see that???
Thanks, it's working well now.
Related to the default button issue, it'd be nice if the CButton class had GetStyle/SetStyle methods and the CDialog class had SetDefaultButton and GetDefaultButton methods.
I believe all classes derived from CWindow have the ModifyStyle method, but I don't know about a GetStyle.