In DDT, when dialog loses and then gains focus again, focus seems
to be set to default button no matter how we do. Wrote a sample
to show problem. Focus is set to textbox on startup. Switch to
another program and back again, textbox has lost focus to button.
Trying to intercept dialog's WM_SETFOCUS has no effect. This only
happens in DDT, not if dialog is created SDK way. What's up, and
how can it be "fixed"?
I know one can use %BM_SETSTYLE and %BS_DEFPUSHBUTTON to change
default button, but how can one set another type of control to be
"default" - in DDT, since the engine seems to override %WM_SETFOCUS
calls in dialog Callback and do stuff after it's handled?
------------------
[This message has been edited by Borje Hagsten (edited January 09, 2001).]
to be set to default button no matter how we do. Wrote a sample
to show problem. Focus is set to textbox on startup. Switch to
another program and back again, textbox has lost focus to button.
Trying to intercept dialog's WM_SETFOCUS has no effect. This only
happens in DDT, not if dialog is created SDK way. What's up, and
how can it be "fixed"?
I know one can use %BM_SETSTYLE and %BS_DEFPUSHBUTTON to change
default button, but how can one set another type of control to be
"default" - in DDT, since the engine seems to override %WM_SETFOCUS
calls in dialog Callback and do stuff after it's handled?
Code:
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ #COMPILE EXE #INCLUDE "WIN32API.INC" DECLARE CALLBACK FUNCTION DlgProc() AS LONG '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Main callback '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ CALLBACK FUNCTION DlgProc() AS LONG SELECT CASE CBMSG CASE %WM_INITDIALOG SetFocus GetDlgItem(CBHNDL, 20) '<- This works fine CASE %WM_COMMAND IF CBCTL = 11 THEN DIALOG END CBHNDL, 1 '<- Exit CASE %WM_SETFOCUS SetFocus GetDlgItem(CBHNDL, 20) '<- This don't, in DDT END SELECT END FUNCTION '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ ' Create dialog and controls, etc '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ FUNCTION PBMAIN () AS LONG LOCAL hDlg AS LONG DIALOG NEW 0, "Focus test ",,, 130, 106, %WS_SYSMENU, 0 TO hDlg CONTROL ADD BUTTON, hDlg, 10, "Ok", 10, 10, 50, 14 CONTROL ADD BUTTON, hDlg, 11, "E&xit", 60, 10, 50, 14 CONTROL ADD TEXTBOX, hDlg, 20, "", 0, 30, 126, 60, _ %ES_WANTRETURN OR %ES_MULTILINE, %WS_EX_CLIENTEDGE DIALOG SHOW MODAL hDlg CALL DlgProc END FUNCTION
[This message has been edited by Borje Hagsten (edited January 09, 2001).]
Comment