Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trap a key pressed in a dialog procedure
#1
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.
#2
Function Dialog163
Code:
Copy      Help
\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
#3
Many thanks, indeed !

However, let me please ask one further question : Is it possible to know the field on which the ST was keyed?
#4
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.
#5
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.
#6
Thank you so much, once more.

GetDlgCtrlID(GetFocus) works perfectly.


Forum Jump:


Users browsing this thread: 1 Guest(s)