Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog box defines hotkeys
#1
Hello everyone 
I defined a hotkey in the dialog box, Ctrl+q, add or remove # use for The line where the cursor is located, but  it only has an effect on the first line

Thanks for any advice and help
david

Macro Macro5
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54031084 0x200 8 8 204 94 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
e3=
;ABC
;#DEF
;GHI
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "401 Cq")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 401
,act id(3 hDlg)
,key E SH
,_s.getsel
,if _s.beg("#")
,,_s.findreplace("#" "" 4)
,,_s.setsel
,else
,,_s.ltrim
,,_s-"#"
,,_s.setsel
#2
The Ctrl from the hotkey is still pressed, and instead of Home you get Ctrl+Home etc, and it selects entire text.
The easiest way to fix it - insert this before the key E SH line:
,key- C

Also the dialog now cannot be closed. Add this at the end:
ret 1
#3
@Gintaras

Thanks for your help
#4
@Gintaras

I have an idea Idea  Is it possible?

When I press the middle mouse button in the edit box, do the same as the hotkey Ctrl+Q

I didn't find an event where the middle mouse button was pressed

Sometimes, mouse operation is more convenient than key operation
#5
Not very easy in QM. Need to subclass the control.

Function Dialog249
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54030080 0x200 56 8 96 12 ""
;4 Static 0x54000000 0x0 4 8 48 12 "Middle click"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

;OutWinMsg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowSubclass(id(3 hDlg) &sub.WndProc_Subclass1 1 0)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1



#sub WndProc_Subclass1
function# hwnd message wParam lParam uIdSubclass dwRefData

;This function can be used with SetWindowSubclass as window procedure.
;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)


;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_MBUTTONDOWN
,out "middle down"
,case WM_MBUTTONUP
,out "middle up"

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass1 uIdSubclass)
,
,;case ...

ret R
#6
Thanks!
This works Well
#7
I want to select the current row by double-click, 
I have to add a delay to stay selected, Later, the selection is automatically deselected! Why?  Huh
Line51

Macro Macro9
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 8 8 208 96 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""

str controls = "3"
str e3
e3=
;Hello world!
;Hello world!

if(!ShowDialog(dd &sub.DlgProc &controls)) ret

#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SetWindowSubclass(id(3 hDlg) &sub.WndProc_Subclass_Edit 1 0)
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK

,case IDCANCEL
ret 1

#sub WndProc_Subclass_Edit
function# hwnd message wParam lParam uIdSubclass dwRefData
;https://www.quickmacros.com/forum/showthread.php?tid=7241&pid=35624#pid35624

;This function can be used with SetWindowSubclass as window procedure.
;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)

;OutWinMsg message wParam lParam ;;uncomment to see received messages

sel message
,case WM_MBUTTONDOWN 
,
,case WM_MBUTTONUP
,
,case WM_LBUTTONDBLCLK
,key ESH         ;; End Shift+Home-------------------------------------------------------Todo
,3

int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass_Edit uIdSubclass)
,
,;case ...
ret R
#8
In dialogs don't use "wait", it has no sense. If need a delay, use a timer. Or move the code to another thread.
And avoid key and mouse functions. In this case can be used messages EM_GETSEL and EM_SETSEL.
#9
I don't quite understand how to use messages EM_GETSEL and EM_SETSEL
#10
In this case key works too, but need ret.

Code:
Copy      Help
,case WM_LBUTTONDBLCLK
,;SendMessage(hwnd EM_SETSEL 3 6)
,key ESH
,ret
#11
use ret worked welll
thank you so much


Forum Jump:


Users browsing this thread: 2 Guest(s)