Posts: 1,031
Threads: 246
Joined: Jul 2022
07-21-2022, 10:35 AM
(This post was last modified: 07-21-2022, 10:46 AM by Davider.)
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
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
Posts: 12,073
Threads: 140
Joined: Dec 2002
07-21-2022, 11:16 AM
(This post was last modified: 07-21-2022, 11:22 AM by Gintaras.)
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
Posts: 1,031
Threads: 246
Joined: Jul 2022
07-21-2022, 11:23 AM
(This post was last modified: 07-21-2022, 11:23 AM by Davider.)
@ Gintaras
Thanks for your help
Posts: 1,031
Threads: 246
Joined: Jul 2022
08-05-2022, 08:01 AM
(This post was last modified: 08-05-2022, 08:02 AM by Davider.)
@ Gintaras
I have an 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
Posts: 12,073
Threads: 140
Joined: Dec 2002
Not very easy in QM. Need to subclass the control.
Function Dialog249
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
Posts: 1,031
Threads: 246
Joined: Jul 2022
Posts: 1,031
Threads: 246
Joined: Jul 2022
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?
Line51
Macro Macro9
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
Posts: 12,073
Threads: 140
Joined: Dec 2002
09-05-2022, 05:27 AM
(This post was last modified: 09-05-2022, 05:38 AM by Gintaras.)
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.
Posts: 1,031
Threads: 246
Joined: Jul 2022
I don't quite understand how to use messages EM_GETSEL and EM_SETSEL
Posts: 12,073
Threads: 140
Joined: Dec 2002
In this case key works too, but need ret.
,case WM_LBUTTONDBLCLK
,;SendMessage(hwnd EM_SETSEL 3 6)
,key ESH
,ret
Posts: 1,031
Threads: 246
Joined: Jul 2022
09-05-2022, 10:11 PM
(This post was last modified: 09-07-2022, 12:29 AM by Davider.)
use ret worked welll
thank you so much
|