Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modal Windows display and return text
#4
if you want to share variables with subfunctions you need to declare them in the main function. Then can use v attribute .

here is an alternative way.
Code:
Copy      Help
int sci
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
,case WM_APP+10 ;;receive text from child dialog
,str& txt=+lParam
,txt.setwintext(id(3 hDlg))    
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 4 ;;Sci_Editor
,sub.Sci_Editor(hDlg)
ret 1

#sub Sci_Editor
function# [hwndOwner]

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 "*" "" "" ""

ShowDialog(dd &sub.DlgProc_Sci 0 hwndOwner)

#sub DlgProc_Sci v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,sci=id(3 hDlg)
,str text
,text.getwintext(id(3 GetParent(hDlg)))
,sub.SetText(text)
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,sub.GetText(text)
,SendMessage GetParent(hDlg) WM_APP+10 hDlg &text 
,case IDCANCEL
ret 1

#sub Sci v
function# message [param1] [param2]
ret SendMessage(sci message param1 param2)

#sub Sci2 v
function# message [param1] [$text]
ret SendMessage(sci message param1 text)

#sub GetText v
function str&text
int n=SendMessage(sci SCI.SCI_GETTEXTLENGTH 0 0)
text.fix(SendMessage(sci SCI.SCI_GETTEXT n+1 text.all(n)))

#sub SetText v 
function $text
sub.Sci2(SCI.SCI_SETTEXT 0 text)

as far as your paste error it's from this.

_s.setsel(id(3 hDlg)) ;;err: cannot paste

should be,

Code:
Copy      Help
_s.setsel(0 id(3 hDlg))


Messages In This Thread
RE: Modal Windows display and return text - by Kevin - 02-08-2023, 05:10 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)