I have this code from some timeback in the forum. I am using it in this large program that I have and it works fine.
Now was going to post a problem I was having using it in different place. So started to make a small sample code
to show the problem I was having. But the sample program I tried making does not work. Where is the problem?
What the code was to do was to enter text in the textbox and press the enter key and focus goes to the done button.
Then when the focus is in the done button , pressing up arrow or left arrow the focus would return to the textbox.
This code I do not understand 100% . One thing I left out is the Accelerator code.
Would like to see if this code can be made to work to do just what is discribe above.
After this code is fixed will add another sample code to describe the second problem I was having.
Now was going to post a problem I was having using it in different place. So started to make a small sample code
to show the problem I was having. But the sample program I tried making does not work. Where is the problem?
What the code was to do was to enter text in the textbox and press the enter key and focus goes to the done button.
Then when the focus is in the done button , pressing up arrow or left arrow the focus would return to the textbox.
This code I do not understand 100% . One thing I left out is the Accelerator code.
Would like to see if this code can be made to work to do just what is discribe above.
After this code is fixed will add another sample code to describe the second problem I was having.
Code:
#COMPILE EXE #INCLUDE "WIN32API.INC" GLOBAL hDlg AS DWORD , TEXT1 AS STRING CALLBACK FUNCTION PBMAIN_DlgProc() AS LONG '*** ???? VVV ************************************************************************************************* SELECT CASE CBMSG CASE %WM_INITDIALOG ' ensure keyboard shortcut visual cues are visible (eg underscored 'L' on LOOKUP btn) DIALOG SEND CBHNDL, %WM_CHANGEUISTATE, MAK(LONG, %UIS_CLEAR, %UISF_HIDEFOCUS OR %UISF_HIDEACCEL), 0 CASE %WM_COMMAND IF CBCTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN ' (NB. "Or CB.CtlMsg = 1" for when msg from an accelerator SELECT CASE CBCTL ' Which Control ID or Accelerator CMD? 'CASE %Key_Down ' DIALOG POST CBHNDL, %WM_NEXTDLGCTL, 0, 0 ' The WM_NEXTDLGCTL message is sent to a dialog box ' procedure to set the keyboard focus to a different control ' in the Dialog. (0, 0 => next control to receive focus) 'CASE %Key_UP ' DIALOG POST CBHNDL, %WM_NEXTDLGCTL, 1, 0 ' (1, 0 => previous control to receive focus) CASE %IDOK ' Enter key notification to Dialog IF GetFocus = GetDlgItem(CBHNDL, 201) THEN 'MsgBox "Process now?", %MB_ICONMASK, "" ' option to auto process after last entry CONTROL SET FOCUS hDlg,201 ELSE DIALOG POST CBHNDL, %WM_NEXTDLGCTL, 0, 0 END IF CASE 100 ' DONE Btn clicked 'MsgBox "Process now?", %MB_ICONMASK, "" CONTROL SET FOCUS hDlg,201 END SELECT END IF END SELECT '*** ???? *************************************************************************************************** END FUNCTION CALLBACK FUNCTION DONE1() AS LONG CONTROL GET TEXT hDlg, 201 TO TEXT1 CONTROL SET TEXT hDlg, 200, TEXT1 CONTROL SET FOCUS hDlg, 201 END FUNCTION FUNCTION PBMAIN() AS LONG DIALOG NEW 0, "Dialog 1",,,300,300, %WS_SYSMENU, 0 TO hDlg LOCAL result AS LONG CONTROL ADD LABEL, hDlg, -1,"Enter Selection No. : " , 70, 210, 120, 15, CONTROL ADD LABEL, hDlg, 200 ,"TEXTBOX" ,120, 150, 80, 15, CONTROL ADD TEXTBOX, hDlg, 201 ,"" , 50, 230, 80, 15, CONTROL ADD BUTTON, hDlg, 100 ,"&1 DONE" ,140, 230, 50, 15, CALL DONE1 CONTROL ADD BUTTON, hDlg, 101 ,"&0 Cancel" ,200, 230, 50, 15, 'CALL XXXX CONTROL SET FOCUS hDlg, 201 DIALOG SHOW MODAL hDlg CALL PBMAIN_DlgProc TO result END FUNCTION
Comment