Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Attach a Run to a Dialogue Button
#1
Hello

Totally new to QM.

How do I attach a command to a button on a dialogue to run a file/program.Thanks you for your help. It is much appreciated.
 
Kind regards
 
Alex
#2
open qm dialog editor
 on the dialog editor window select the control(button in this case) you want to execute code from
then click the events buttons.(the lightning icon)
   

it will open another window
   

select BN_CLICKED
click ok on that window
it will insert code for that event into the dialog procedure
Then just need to add run code

example with run program and open file two buttons
Function DialogRunOrOpenFile
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Button 0x54032000 0x0 33 48 48 14 "Run" "click to run or open file"
;4 Button 0x54032000 0x0 144 48 48 14 "Open"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040C00 "*" "" "" ""

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 ;;Run
,run "$windows$\notepad.exe";; run notepad
,case 4 ;;Open
,run "$qm$\License.txt"
ret 1
#3
Hello Kevin

Many thanks for your reply.

When I click on the events, I get a message 
"Cannot find Dialogue Procedure
It must be in the same macro/function where is the dialogue definition
More info in QM output

What am I doing wrong?Thanks you for your help. It is much appreciated.
 
Kind regards
 
Alex
#4
Add this line to the beginning of the function above.
\Dialog_Editor
#5
Your dialog needs to be a smart dialog.

the error message shows you how to fix it. The dialog must have a Dialogue Procedure. In qm output it gives you a sample code to fix the issue..
Sample ShowDialog code and dialog procedure:
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
ret 1
 close dialog editor
find this line in 

if(!ShowDialog(dd 0 0)) ret

replace with sample code

then reopen dialog editor and follow instructions given above.

or can re make the dialog as a smart dialog.


Forum Jump:


Users browsing this thread: 1 Guest(s)