May 08, 2024, 11:41:32 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Dialog Editor Question

Started by Bruce Peaslee, February 03, 2006, 05:38:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

The ownerdraw style is needed for color buttons.  If you check the "XP compatible" checkmark then it will be a standard button.

Paul.
Ionic Wind Support Team

Ionic Wind Support Team

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.

Ionic Wind Support Team

Ionic Wind Support Team

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.
Ionic Wind Support Team

Bruce Peaslee

Sounds good. I used

const BS_DEFPUSHBUTTON = 1;

which of course is the same value.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Bruce Peaslee

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?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

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
Ionic Wind Support Team

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Mike Stefanik

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.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Parker

I believe all classes derived from CWindow have the ModifyStyle method, but I don't know about a GetStyle.