02-08-2023, 02:42 AM
I want to modify the selected text, but an error message(cannot paste) appears when return
Macro Macro6
,case 4 ;;Sci_Editor
,act id(3 hDlg)
,_s.getsel
,out _s
,if empty(_s)
,,_i=1
,,_s.getwintext(id(3 hDlg))
,if sub.Sci_Editor(hDlg _s)
,,out _s
,,if _i
,,,_s.setwintext(id(3 hDlg))
,,else
,,,act id(3 hDlg)
,,,_s.setsel(id(3 hDlg)) ;;err: cannot paste
Macro Macro6
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Edit 0x54231044 0x200 8 8 208 100 ""
;4 Button 0x54032000 0x0 28 116 48 14 "Sci_Editor"
;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
;thank you for your help
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 ;;Sci_Editor
,act id(3 hDlg)
,_s.getsel
,out _s
,if empty(_s)
,,_i=1
,,_s.getwintext(id(3 hDlg))
,if sub.Sci_Editor(hDlg _s)
,,out _s
,,if _i
,,,_s.setwintext(id(3 hDlg))
,,else
,,,act id(3 hDlg)
,,,_s.setsel(id(3 hDlg)) ;;err: cannot paste
ret 1
#sub Sci_Editor
function# [hwndOwner] [~&txt]
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 346 206 "Dialog" "4"
;3 Scintilla 0x54000000 0x20000 0 0 346 184 ""
;1 Button 0x54030001 0x4 232 188 48 14 "OK"
;2 Button 0x54030000 0x4 288 188 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C02 "*" "" "" ""
str+ tt=txt ;;ok
int+ sci
str contrls="3"
str s3
if(!ShowDialog(dd &sub.DlgProc_Sci &contrls hwndOwner)) ret
txt=s3
ret 1
#sub DlgProc_Sci v
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,sci=id(3 hDlg)
,;sub.SetText(txt) ;;no
,sub.SetText(tt) ;;ok
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#sub Sci2 v
function# message [param1] [$text]
ret SendMessage(sci message param1 text)
#sub SetText v
function $text
sub.Sci2(SCI.SCI_SETTEXT 0 text)