When I try the WidgetDialog sample, I observe:
1) If the focus is in the text box, and I press Enter, it invokes the default pushbutton.
2) Esc causes an IDCANCEL button invocation.
It is true that BS_DEFAULTPUSHBUTTON does not affect buttons in WidgetWindows, such as in WidgetButton.
Sorry for not being more specific, I tested only the pure modal dialog in the WidgetDialog example. It doesn't work there, but it works on the resource modal dialog.
So the problem is only with pure modal dialogs...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK, I think I know the reason...
In MessageMap.h, on sendWidgetMessage, the WM_COMMAND msg is routed to children.
In mainWndRouteChild, the msg is wrongly assumed to be from a menu.
So,
if ( ( msg == WM_COMMAND && lPar == 0 && HIWORD( wPar ) == 0 ) || etc.
should be actually,
if ( ( msg == WM_COMMAND && lPar == 0 && HIWORD( wPar ) == 0 && LOWORD(wPar) != IDCANCEL && LOWORD(wPar) != IDOK ) || etc.
BUT, probably it shouldn't be routed to children at all... So, I don't know what is the "right" way to fix this. My guess is to change sendWidgetMessage for these special cases of WM_COMMAND and invoke the default button onClick event or end the dialog accordingly.
And I have no idea why it works on resource based dialogs...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In WidgetButton's Seed class, add the following function:
void setControlId( int id ) {
menuHandle= id;
}
Then before you create a button, use a seed, and call the above function with either IDCANCEL or IDOK.
WidgetButton::Seed cancelSeed; cancelSeed.setControlId( IDCANCEL );
itsCancelButton = createButton( cancelSeed );
...
WidgetButton::Seed okSeed; okSeed.setControlId( IDOK );
itsOkButton = createButton( okSeed );
(I did this in WidgetModalDialog's NumDialog.h, and it gave me the Esc and Enter behaviour.)
And since SmartWin++ did not have a way for Pure dialogs to specify the control identifier, then the pure dialog lacked the Esc and Enter functionality. The resource based dialog specifies the control id, and thus had the functionality.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=1157678
Originator: NO
When I try the WidgetDialog sample, I observe:
1) If the focus is in the text box, and I press Enter, it invokes the default pushbutton.
2) Esc causes an IDCANCEL button invocation.
It is true that BS_DEFAULTPUSHBUTTON does not affect buttons in WidgetWindows, such as in WidgetButton.
See Dialog Box Keyboard Interface at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/aboutdialogboxes.asp
Are you using a button on a modal dialog, modeless dialog, or a WidgetWindow ?
Logged In: YES
user_id=1103883
Originator: YES
Sorry for not being more specific, I tested only the pure modal dialog in the WidgetDialog example. It doesn't work there, but it works on the resource modal dialog.
So the problem is only with pure modal dialogs...
Logged In: YES
user_id=1103883
Originator: YES
OK, I think I know the reason...
In MessageMap.h, on sendWidgetMessage, the WM_COMMAND msg is routed to children.
In mainWndRouteChild, the msg is wrongly assumed to be from a menu.
So,
if ( ( msg == WM_COMMAND && lPar == 0 && HIWORD( wPar ) == 0 ) || etc.
should be actually,
if ( ( msg == WM_COMMAND && lPar == 0 && HIWORD( wPar ) == 0 && LOWORD(wPar) != IDCANCEL && LOWORD(wPar) != IDOK ) || etc.
BUT, probably it shouldn't be routed to children at all... So, I don't know what is the "right" way to fix this. My guess is to change sendWidgetMessage for these special cases of WM_COMMAND and invoke the default button onClick event or end the dialog accordingly.
And I have no idea why it works on resource based dialogs...
Logged In: YES
user_id=1157678
Originator: NO
I have a fix.
In WidgetButton's Seed class, add the following function:
void setControlId( int id ) {
menuHandle= id;
}
Then before you create a button, use a seed, and call the above function with either IDCANCEL or IDOK.
WidgetButton::Seed cancelSeed; cancelSeed.setControlId( IDCANCEL );
itsCancelButton = createButton( cancelSeed );
...
WidgetButton::Seed okSeed; okSeed.setControlId( IDOK );
itsOkButton = createButton( okSeed );
(I did this in WidgetModalDialog's NumDialog.h, and it gave me the Esc and Enter behaviour.)
The reasoning is from MSDN
"To permit the user to close the dialog box, the template should specify at least one push button and give it the control identifier IDCANCEL. To permit the user to choose between completing or canceling the task associated with the dialog box, the template should specify two push buttons, labeled OK and Cancel, with control identifiers of IDOK and IDCANCEL, respectively."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/aboutdialogboxes.asp
And since SmartWin++ did not have a way for Pure dialogs to specify the control identifier, then the pure dialog lacked the Esc and Enter functionality. The resource based dialog specifies the control id, and thus had the functionality.
Logged In: YES
user_id=1103883
Originator: YES
Works for me.... I missed that entirely. Now I get it. Thank you very much!
Logged In: YES
user_id=1221788
Originator: NO
Is this something that's going to be added to cvs, or should we do it ourselves?