Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create dialog and interact with it
#1
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
Code:
Copy      Help
\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
#2
str s="new text"
s.setwintext(id(3 "Macro en cours"))
#3
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
Code:
Copy      Help
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?
#4
flag 1 - modeless dialog.
And need to process messages.
Function Dialog210
Code:
Copy      Help
\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
#5
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?
#6
Move the dialog code to the macro.
str controls...DestroyWindow hDlg

But usually it is better to show dialog in other thread.
#7
Yes, but

mac Dialog210

does not work..
#8
Macro Macro2170
Code:
Copy      Help
mac "Dialog210"
int w=wait(30 WV win("Macro en cours" "#32770"))
Let Dialog210 be normal modal dialog, like your initial code.
#9
Function Macro21
Code:
Copy      Help
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
Code:
Copy      Help
\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?
#10
For example, pass dialog name to the Dialog2 thread as mac argument 2.
Then in Dialog2:
Code:
Copy      Help
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
#11
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
Code:
Copy      Help
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?
#12
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...
#13
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...
#14
Ok, was a typo, working here.

Many thanks, as usual.
#15
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?
#16
Macro Macro2173
Code:
Copy      Help
;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]
#17
Marvelous..


Forum Jump:


Users browsing this thread: 1 Guest(s)