Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I'm a dialog VIRGIN, help!
#1
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
#2
What should happen when you click a button?:
close dialog and type Hello/Goodbye
or
type Hello/Goodbye and don't close dialog
#3
close dialog and type Hello/Goodbye
#4
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.
#5
Example for "simple" dialog.

Function Dialog191
Code:
Copy      Help
\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
Code:
Copy      Help
\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
Code:
Copy      Help
\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
#6
i ran all 3 and none appear to work
#7
wait, the first one does, i wasnt aware i had to edit them to take out the green
#8
They should display Hello or Goodbye in QM output pane.
#9
this is amazing, thanks...

if I have any more questions about this script ill reply
#10
how can I add more than 1 button? like 3 or 4?
#11
Don't know how to open it in Dialog Editor? Or how to add 'case' for new buttons?
#12
I figured it out!

Code:
Copy      Help
\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"
     ...
#13
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


Forum Jump:


Users browsing this thread: 2 Guest(s)