Posts: 795
Threads: 136
Joined: Feb 2009
Hi Gintaras, hi all
searched the forum but unlucky so i try here.
Created a simple dialog with only a static text in it.
Function Dialog2
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str c3one
if(!ShowDialog("Dialog2" &Dialog2 &controls)) ret
;BEGIN DIALOG
;0 "" 0x10C00AC8 0x0 0 0 224 131 "Macro en cours"
;3 Static 0x54000001 0x8000000 88 22 48 10 "Text"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""
ret
;messages
sel message
,case WM_LBUTTONDBLCLK
,DT_Cancel hDlg
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Would like to launch it, and from another macro be able to change the static text on demand.
How to achieve that?
thanks
Posts: 12,074
Threads: 141
Joined: Dec 2002
str s="new text"
s.setwintext(id(3 "Macro en cours"))
Posts: 795
Threads: 136
Joined: Feb 2009
Yes, i did that, but i does not work.
The dialog is launched and i can't continue with code after ShowDialog statement.
Function Macro21
str controls = "3"
str e3Nam
ShowDialog("Dialog2" &Dialog2 &controls)
out "tttt"
What i'd like is
code....
ShowDialog.....
Code continues here
_s="kkkkk"
_s.setwintext(id(3 "Macro en cours"))
Code conit,ues
Close Dialog
For now i must have:
** one function to define the dialog & proc (Dialog2)
** one function to launch the dialog
str controls = "3"
str e3Nam
ShowDialog("Dialog2" &Dialog2 &controls)
out "tttt"
** one function to interact with the dialog window.
_s="kkkkk"
_s.setwintext(id(3 "Macro en cours"))
I'd like two last to be the same.
Possible?
Posts: 12,074
Threads: 141
Joined: Dec 2002
flag 1 - modeless dialog.
And need to process messages.
Function Dialog210
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3"
str c3one
hDlg=ShowDialog("Dialog210" &Dialog210 &controls 0 1)
opt waitmsg 1
1
_s="kkkkk"
_s.setwintext(id(3 hDlg))
1
DestroyWindow hDlg
;BEGIN DIALOG
;0 "" 0x10C00AC8 0x0 0 0 224 131 "Macro en cours"
;3 Static 0x54000001 0x8000000 88 22 48 10 "Text"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""
ret
;messages
sel message
,case WM_LBUTTONDBLCLK
,DT_Cancel hDlg
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Posts: 795
Threads: 136
Joined: Feb 2009
Sorry, i was not clear as it is absolutly not what I want to do.
I want:
1. launch a dialog from a macro (say macro1).
2. then that macro1 contnues to do it's job.
3. during it's job, it modifies dialog controls
4. at then end of macro1, destroys dialog
Is it clearer?
Posts: 12,074
Threads: 141
Joined: Dec 2002
Move the dialog code to the macro.
str controls...DestroyWindow hDlg
But usually it is better to show dialog in other thread.
Posts: 795
Threads: 136
Joined: Feb 2009
Yes, but
mac Dialog210
does not work..
Posts: 12,074
Threads: 141
Joined: Dec 2002
Macro Macro2170
mac "Dialog210"
int w=wait(30 WV win("Macro en cours" "#32770"))
Let Dialog210 be normal modal dialog, like your initial code.
Posts: 795
Threads: 136
Joined: Feb 2009
Function Macro21
mac "Dialog2"
int w=wait(30 WV win("Macro en cours" "#32770"))
for _i 0 10
,_s=_i
,_s.setwintext(id(3 w))
,0.5
clo w
Function Dialog2
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
if(!ShowDialog("Dialog2" &Dialog2)) ret
;BEGIN DIALOG
;0 "" 0x10C00AC8 0x0 0 0 224 131 "Macro en cours"
;3 Static 0x54000001 0x8000000 88 22 48 10 "Text"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""
ret
;messages
sel message
,case WM_LBUTTONDBLCLK
,DT_Cancel hDlg
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
seems work
1. is code correct?
2. Can I assign the dialog a name at runtime to have multiple dialogs running from different macros?
Posts: 12,074
Threads: 141
Joined: Dec 2002
For example, pass dialog name to the Dialog2 thread as mac argument 2.
Then in Dialog2:
str dd=
F
;BEGIN DIALOG
;0 "" 0x10C00AC8 0x0 0 0 224 131 "{_command}"
;3 Static 0x54000001 0x8000000 88 22 48 10 "Text"
;END DIALOG
;DIALOG EDITOR: "" 0x2030605 "" "" "" ""
if(!ShowDialog(dd &Dialog2)) ret
Posts: 795
Threads: 136
Joined: Feb 2009
Hmm..
as mac lauches Dialog and the macro continues, the name is not modifiable,
unless i can pass arguments to
mac "Dialog2" "name of the dialog"
Function Dialog2
0 "" 0x10C00AC8 0x0 0 0 224 131 "Macro en cours"
"Macro en cours" is what I need to modify, so that
the dialog is created with a custom name.
Possible?
Posts: 12,074
Threads: 141
Joined: Dec 2002
If using code from my previous post, and
mac "Dialog2" "name of the dialog"
then dialog is created with name "name of the dialog".
If it does not work, maybe you now have 2 dialogs - Dialog2 and Dialog210...
Posts: 795
Threads: 136
Joined: Feb 2009
oops, seems i answered with a different post. sorry.
but it does always name the dialog {_command} so there is some code i did not copy correctly...
Posts: 795
Threads: 136
Joined: Feb 2009
Ok, was a typo, working here.
Many thanks, as usual.
Posts: 795
Threads: 136
Joined: Feb 2009
As I get ideas often, just a complement.
Is it possible to give those dialog a special dummy property (say a class) which would allow me
to show/hide say 3 different dialog2 windows with different names via a hotkey?
Would allow to monitor at demand and unclutter desktop at will.
Possible?
Posts: 12,074
Threads: 141
Joined: Dec 2002
Macro Macro2173
;set a window property
int w1=win("Untitled - Notepad" "Notepad")
int w2=win("Calculator" "CalcFrame")
SetProp w1 "dummy_prop" 1
SetProp w2 "dummy_prop" 1
;_______________________________
;find all windows that have the property
ARRAY(int) a; int i
opt hidden 1
win("" "" "" 0x0 "GetProp=dummy_prop" a)
opt hidden 0
for(i 0 a.len) outw a[i]
Posts: 795
Threads: 136
Joined: Feb 2009
|