Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Macros output in Dialog window ?
#1
Hello !

I'm just beginning with dialogs, and i would like to have the output of my macros in the dialog box

I saw this thread : "dialog.exe" program output in the dialog window?
But it's not what i exactly want to do

Here is my dialog box atm :

[Image: f8e112e317.png]

Here is the code :

Macro Test5
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 396 282 "Dialog"
;10 Edit 0x54030080 0x200 12 152 374 72 ""
;3 Button 0x54032000 0x0 132 32 118 14 "Macro 1"
;4 Button 0x54032000 0x0 132 52 118 14 "Macro 2"
;1 Button 0x54030001 0x4 12 228 156 46 "OK"
;2 Button 0x54030000 0x4 196 228 194 46 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040304 "*" "" "" ""


str controls = "10"
str e10
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 Execution
ret


;Execution
sel wParam
,case 3
,mac "Macro 1"
,ret
,
,case 4
,mac "Macro 2"

,case IDOK
,out "Clicked on OK"
,ret
ret 1

For example, when i click on "Macro 1", it launches "Macro 1"

if Macro1=
Code:
Copy      Help
out "Macro 1 launched !"
How can i "export" the output of "Macro 1" in the dialog Box ?

Thanks in advance !
#2
I don't know if this is a good approach.
(Make sure the below dialog is a dialog item, which you can create by "File" >> "New" >> "New Dialog".)
Don't put the dialog code in a macro.

Read more about this in:
Having Trouble Setting up Simple User-Defined Function
You should be navigated to the correct response of Gintaras, If you are not automatically navigated to it then do a [CONTROL] + [F] in your browser and search for: Functions can execute the same code as

Function output_test
Code:
Copy      Help
\Dialog_editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 396 282 "Dialog"
;10 Edit 0x54030080 0x200 12 152 374 72 ""
;3 Button 0x54032000 0x0 134 29 124 21 "Macro # (PRESS THIS BUTTON!)"
;5 Static 0x54000000 0x0 71 55 272 74 "Each time you press the above button, a small random string should appear in the outputbox below.[][]The random string is:[]- Generated in ''Macro#''[]- Send from ''Macro#'' to THIS outputbox below.[][]Macro#, is the Macro name you assigned to this button to generate and send the string here."
;1 Button 0x54030001 0x4 12 228 156 46 "OK"
;2 Button 0x54030000 0x4 196 228 194 46 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040308 "*" "" "" ""


str controls = "10"
str e10
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 Execution
ret

;Execution
sel wParam
,case 3
,,;; the "hDlg" (dialog control ID) is passed as a STRING parameter to "Macro19"
,,mac "Macro19" hDlg
,case IDOK
,out "Clicked on OK"
,ret
ret 1


Macro Macro19
Code:
Copy      Help
str dlg_id=_command ;; _command is reserved container which always contains arguments send to macro/function/...
int hDlg=val(dlg_id)
str s.RandomString(5 5 "A-Z0-9")
s.setwintext(id(10 hDlg))
#3
Hello !

Thanks ! Your code works, i will investigate and learn on how it works

However, Macro19 must be a function, not a macro

If it's a macro, this message appears :
"Warning (RT) in Test5Big GrinlgProc: launching macro from macro. The second macro will start later. You may want to change 'If a macro is running' option or convert to function."

But anyway, it works, thanks Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)