Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Dialogue Box
#1
I'm a newbie Quick Macros user, so please bear with me for being a moron...

I want to create a dialog (or input or message or whatever the best description of it is) box that pops up with two options. If the user selects option 1, it goes to point A in the macro. If the user selects option 2, it goes to point B in the macro.

It seems like this should be drop dead easy, but all the documentation and forum posts I've found are so detailed and complex, it's overwhelming. I've yet to find any instructions or examples for how to do something so simple. Can anyone advise?

Thanks!
#2
Below some examples:

example_goto: uses a MACRO to show simple goto example
example_goto_using_messagebox: uses a MACRO with messabox
example_goto_using_listbox_1 AND example_goto_using_listbox_2: uses a MACRO with a listbox
example_goto_like_dialog:  uses an DIALOG with subfunction


Macro example_goto
Code:
Copy      Help
;This example uses 'goto' in a qm macro.
;;;Macro: green play icon which you see at the left in your qm items list if you used:  File > New > New Macro
;;;Function: Blue rhombus/diamond icon which you see at the left in your qm items list if you used: File > New > New Function
;Below you see 'skipped_to_this_point' in green which is a LABEL which is used by the command:
;'goto skipped_to_this_point'
;As you see comments can also be LABELS

goto skipped_to_this_point

mes("This messagebox should NOT be rendered")

;skipped_to_this_point

mes("Hi")


Macro example_goto_using_messagebox
Code:
Copy      Help
;Note: you can also use subfunctions here if you want to

sel mes("Do you want to execute A or B[]Yes = A[]No = B[]Cancel = quits, nothing gets executed" "Choose..." "YNC")
,case 'Y'
,,goto exec_A
,case 'N'
,,goto exec_B
,case 'C'
,,end ;; or 'ret'

mes("This messagebox should NOT be rendered")
;
;exec_A
mes("Executing code at A" "i")
goto continue_code ;; Or put 'end' here or 'ret'. You need to implement some form of "stop" here or else after user clicks 'yes' the code under 'exec_B' also get's executed

;exec_B
mes("Executing code at B" "i")

;continue_code


Macro example_goto_using_listbox_1
Code:
Copy      Help
sel(ListDialog("Goto a[]Goto b" "Choose..."))
,case 1
,,mes("A")
,case 2
,,mes("B")
,case else ret

Macro example_goto_using_listbox_2
Code:
Copy      Help
;; Note that I entered
;70 A
;71 B
;; You can use any id you want.

int iSel=ListDialog("70 A[]71 B" "" "choose..." 0x2)
if(iSel=0)ret ;; empty part clicked or 'Cancel' clicked
if(iSel=70)goto exec_A
if(iSel=71)goto exec_B

mes("This messagebox should NOT be rendered")
;
;exec_A
mes("Executing code at A" "i")
goto continue_code ;; Or put 'end' here or 'ret'. You need to implement some form of "stop" here or else after user clicks 'yes' the code under 'exec_B' also get's executed

;exec_B
mes("Executing code at B" "i")

;continue_code


Function example_goto_like_dialog
Code:
Copy      Help
;Note:
;Because this is a dialog 'goto' is not used.
;Using functions or subfunctions in dialogs makes more sense
;and makes the code a bit more readable.


str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 216 87 "Example goto dialog (using: subfunctions)"
;3 Button 0x54032000 0x0 26 26 48 14 "A"
;4 Button 0x54032000 0x0 89 26 48 14 "B"
;END DIALOG
;DIALOG EDITOR: "" 0x2040601 "*" "" "" ""

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 IDOK
,case IDCANCEL
,case 3
,sub.exec_A ;; This executes below subfunction A
,case 4
,sub.exec_B ;; This executes below subfunction B
ret 1


#sub exec_A
mes(F"Button 'A' pressed!" F"A" "i")


#sub exec_B
mes(F"Button 'B' pressed!" F"B" "i")
Regarding:
example_goto_using_listbox_1 , example_goto_using_listbox_2 and example_goto_using_messagebox

   
   
   
   


Also maybe this post might help, it contains links to different tutorials:
http://www.quickmacros.com/forum/showthr...0#pid29630

If you want to jump straight into dialogs (16 and 17 is probably what you need to get started):
16. https://www.youtube.com/watch?v=Cmh9lrpIiFk
17. https://www.youtube.com/watch?v=CNTbN2v06Sw
18. https://www.youtube.com/watch?v=oxp9eKqj1W0
19. https://www.youtube.com/watch?v=SgBEnfZfDHc
20. https://www.youtube.com/watch?v=rS4WODNcNbs

If you are just beginning QM, jmping straight into functions might be a bit too much.
You may want to begin from the first tutorial.
But if you already have some experience with Macro's, (Sub)Functions and dialogs then you could begin at any point.


Forum Jump:


Users browsing this thread: 1 Guest(s)