Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing ESC key in Smart Dialog
#1
I've been working with QM for about 1 week now and am really impressed with how much it can do. I'm creating a Smart Dialog as a command line for a GUI. I want users to be able to type commands and hit either Enter or click on OK and have the commands processed while leaving the dialog window open and ready for the next command. I've got it set to run as SysModal so it will float over my other applications and have changed my 2 command buttons so that they don't close the dialog, clear out the Edit field, and set the focus on the Edit field. I have a third button, Cancel, hidden by leaving it out of the viewable portion of the dialog box. What I would like to do is:

1. Eliminate the Cancel button completely while still having the X button in the upper-right corner of the dialog box to remain functional.

2. Change what the ESC key does. Instead of having it close the dialog window, I'd rather it clear out my Edit field and set the focus there (like the command buttons do).

Any help I can get would be terrific.

FYI, I'm running QM 2.1.9.1 on Windows XP.
#2
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("Dialog23" &Dialog23)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,ifk(Z)
,,;here add code to clear edit control etc
,,ret
ret 1

You can remove Cancel button. When you click X or press Esc, dialog procedure receives the same command like you would click Cancel. Then you can check for Esc key state...

Another way:
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("Dialog23" &Dialog23)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,case WM_CLOSE
,DT_Cancel hDlg
,ret 1
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,,;here add code to clear edit control etc
,,ret
ret 1
#3
That second method worked like a charm!! Thanks for your help and quick response.


Forum Jump:


Users browsing this thread: 1 Guest(s)