Posts: 1,058
Threads: 367
Joined: Oct 2007
I wonder whether there exist a way to trap a key (namely I am interested in Shift-Tab) in a dialog procedure. I am aware of topic
keypress detect (key translated in VK an readable format), however it didnot lead me me to a solution for this particular inquiry.
Many thanks in advance.
Posts: 12,073
Threads: 140
Joined: Dec 2002
Function
Dialog163
\Dialog_Editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""
if(!ShowDialog(dd &sub.DlgProc 0)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,DT_SetAccelerators hDlg "100 ST"
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 100 mes "Shift+Tab"
ret 1
Posts: 1,058
Threads: 367
Joined: Oct 2007
Many thanks, indeed !
However, let me please ask one further question : Is it possible to know the field on which the ST was keyed?
Posts: 1,058
Threads: 367
Joined: Oct 2007
To solve the latter, I followed this technique :
I issued a
Quote:case EN_SETFOCUS<<16|4
for each one of the fields involved in this inquiry, and I consequently stored the relevant number (4 in the case of this example) in a memory variable. Actually, this variable holds the field in which the Accelerator key was keyed. Any advice about other more efficient solutions is mostly welcome.
Posts: 12,073
Threads: 140
Joined: Dec 2002
GetFocus.
Other ways to get all dialog key messages:
1. Modeless dialog and message loop (GetMessage/TranslateMessage/DispatchMessage).
2. SetWindowsHookEx WH_GETMESSAGE. Look in menu File New Templates.
3. Subclass controls.
Posts: 1,058
Threads: 367
Joined: Oct 2007
Thank you so much, once more.
GetDlgCtrlID(GetFocus) works perfectly.