Posts: 44
Threads: 10
Joined: Aug 2015
I'm trying hard to understand how to use dialog boxes/buttons but the examples are too complicated.
I'd love to see this as an example to understand how they work
1. Run notepad
2. Dialog box: Button 1, Button 2
3. If Button 1, then type Hello. If 2, then type Goodbye
If I saw this example I'd understand how to use them
Thank you
Posts: 12,066
Threads: 140
Joined: Dec 2002
What should happen when you click a button?:
close dialog and type Hello/Goodbye
or
type Hello/Goodbye and don't close dialog
Posts: 44
Threads: 10
Joined: Aug 2015
close dialog and type Hello/Goodbye
Posts: 44
Threads: 10
Joined: Aug 2015
I'm writing scripts for work, and we have a ticket system..
I already wrote a script that will create and fill out the ticket, and there's 2 really really common requests we get all day... 1 is "please unlock/reset my password" and the other is "please unlock, reset my [special software]
I want my workflow t be
Run create ticket script - diaglog box "windows PW or X password"
then when I click one of them it automatically runs 1 of 2 scripts filling it out properly.
Anyway, yeah.
Posts: 12,066
Threads: 140
Joined: Dec 2002
Example for "simple" dialog.
Function Dialog191
\Dialog_Editor
;run "notepad" ;;enable these disabled green lines if really need Notepad
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 8 8 48 14 "Hello"
;4 Button 0x54032000 0x0 8 28 48 14 "Goodbye"
;END DIALOG
;DIALOG EDITOR: "" 0x2040302 "*" "" "" ""
int button=ShowDialog(dd 0 0)
sel button
,case 3
,out "Hello"
,;act "Notepad"; key "Hello"
,;...
,
,case 4
,out "Goodbye"
,;act "Notepad"; key "Goodbye"
,;...
Example for "smart" dialog. The button closes the dialog.
Function Dialog192
\Dialog_Editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 8 8 48 14 "Hello"
;4 Button 0x54032000 0x0 8 28 48 14 "Goodbye"
;END DIALOG
;DIALOG EDITOR: "" 0 "*" "" "" ""
int button=ShowDialog(dd &sub.DlgProc 0)
;out button
sel button
,case 3
,out "Hello"
,;...
,
,case 4
,out "Goodbye"
,;...
#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 [3,4] DT_Ok(hDlg wParam)
,case IDOK
,case IDCANCEL
ret 1
Example for "smart" dialog. The button launches another macro and does not close the dialog.
Function Dialog193
\Dialog_Editor
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Button 0x54032000 0x0 8 8 48 14 "Hello"
;4 Button 0x54032000 0x0 8 28 48 14 "Goodbye"
;END DIALOG
;DIALOG EDITOR: "" 0 "*" "" "" ""
if(!ShowDialog(dd &sub.DlgProc 0)) 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 3
,mac "Hello macro"
,
,case 4
,mac "Goodbye macro"
,
,case IDOK
,case IDCANCEL
ret 1
Posts: 44
Threads: 10
Joined: Aug 2015
i ran all 3 and none appear to work
Posts: 44
Threads: 10
Joined: Aug 2015
wait, the first one does, i wasnt aware i had to edit them to take out the green
Posts: 12,066
Threads: 140
Joined: Dec 2002
They should display Hello or Goodbye in QM output pane.
Posts: 44
Threads: 10
Joined: Aug 2015
this is amazing, thanks...
if I have any more questions about this script ill reply
Posts: 44
Threads: 10
Joined: Aug 2015
how can I add more than 1 button? like 3 or 4?
Posts: 12,066
Threads: 140
Joined: Dec 2002
Don't know how to open it in Dialog Editor? Or how to add 'case' for new buttons?
Posts: 44
Threads: 10
Joined: Aug 2015
I figured it out!
\Dialog_Editor
str dd=
BEGIN DIALOG
0 "" 0x90C80AC8 0x0 0 0 224 136 "What system?"
3 Button 0x54032000 0x0 8 24 48 14 "Windows"
4 Button 0x54032000 0x0 8 60 48 14 "Red Prairie"
5 Button 0x54032000 0x0 8 96 48 14 "JD Edwards"
END DIALOG
DIALOG EDITOR: "" 0x2040202 "*" "" "" ""
int button=ShowDialog(dd 0 0)
sel button
case 3
mac "Unlock_ResetAD"
...
case 4
mac "Unlock_ResetRP"
...
case 5
mac "Unlock_ResetJDE"
...
Posts: 1,006
Threads: 330
Joined: Mar 2007
Tons of Dialog examples in archive:
http://www.quickmacros.com/forum/showthr...p?tid=2852
When posting code to the forum, instead of using option on forum, select text of code in QM editor and then right click --> Other Formats --> Copy for QM Forum: When pasting this back into forum, it will preserve formatting (color, indents, comments, etc). See Gintaras' code example above.
Enjoy the Archive. It's going to blow your mind. You will learn a ton.
Stuart
|