Posts: 726
Threads: 99
Joined: Mar 2018
Use the button to add a substring to a word in the edit box, but the result cannot be returned.
Can someone give some advice? Thanks in advance
Macro Macro3
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 20 12 188 64 ""
;4 Button 0x54032000 0x0 32 92 56 14 "Add sub str"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""
str controls = "3"
str e3
e3="Name"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Add sub str
,_s.getsel
,str s1.from("$inp_" _s "$")
,s1.setsel
ret 1
Posts: 1,337
Threads: 61
Joined: Jul 2006
04-11-2019, 10:18 PM
(This post was last modified: 04-11-2019, 10:19 PM by Kevin.)
it fails because the control doesn't have focus when you click the button
do this
,case 4 ;;Add sub str
,_s.getsel(0 0 id(3 hDlg))
,str s1.from("$inp_" _s "$")
,s1.setsel(0 id(3 hDlg))
Posts: 726
Threads: 99
Joined: Mar 2018
Thanks for your help, the result is wrong, I need to get the result: $inp_Name$
I added the hotkey Alt+Z and it got the correct result, I don't know how to use the button to achieve
Macro Macro3
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 20 12 188 64 ""
;4 Button 0x54032000 0x0 32 92 56 14 "Add sub str"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""
str controls = "3"
str e3
e3="Name"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,DT_SetAccelerators(hDlg "400 Az")
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Add sub str
,_s.getsel
,str s1.from("$inp_" _s "$")
,;s1.setsel ;;BUG
,s1.setsel(0 id(3 hDlg))
,
,case 400 ;;Add sub str
,_s.getsel
,str s2.from("$inp_" _s "$")
,s2.setsel
ret 1
Posts: 1,337
Threads: 61
Joined: Jul 2006
04-12-2019, 12:17 AM
(This post was last modified: 04-12-2019, 12:29 AM by Kevin.)
I disagree the result was not wrong
tested on windows 7 and windows 10 as a macro and a function
before clicking the button
after clicking the button
fullcode
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 20 12 188 64 ""
;4 Button 0x54032000 0x0 32 92 56 14 "Add sub str"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""
str controls = "3"
str e3
e3="Name"
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Add sub str
,_s.getsel(0 0 id(3 hDlg))
,str s1.from("$inp_" _s "$")
,s1.setsel(0 id(3 hDlg))
ret 1
Posts: 726
Threads: 99
Joined: Mar 2018
04-12-2019, 12:40 AM
(This post was last modified: 04-12-2019, 12:44 AM by win.)
Sorry, I only copied the last line of code.
Your code is correct
@kevin
Thank you very much for your help. These details made me understand a lot of things.
error
,_s.getsel
,str s1.from("$inp_" _s "$")
,;s1.setsel ;;BUG
,s1.setsel(0 id(3 hDlg))
correct
,_s.getsel(0 0 id(3 hDlg))
,str s1.from("$inp_" _s "$")
,s1.setsel(0 id(3 hDlg))
|