Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Solved)...Adding a Menu bar to QM Dialog
#1
I have been searching for this on the forum thinking it should be here somewhere but I couldnt find it. I want to add a Menu bar with drop down menus to my Dialog.
[Image: menubarse6.jpg]

Thanks, John
#2
This would be useful if possible.
Taking on Quick Macros one day at a time
#3
It is in QM help.

QM 2.1.9 or later.

Example
Function DialogWithMenu

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str rea3
if(!ShowDialog("DialogWithMenu" &DialogWithMenu &controls 0 0 0 0 0 0 0 "dialog.ico" "DialogWithMenu")) ret

;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x200 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""


ret
;messages
sel message
,case WM_INITDIALOG
,
,case WM_SIZE
,RECT r; GetClientRect(hDlg &r)
,siz r.right r.bottom id(3 hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,;menu items:
,case 101 out "Open"
,case 103 out "Cut"
,case 104 out "Select All"
,case 105 out "Help"
,
,case IDOK
,case IDCANCEL
ret 1

;BEGIN MENU
;>&File

,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit

,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU
#4
Maybe I'm missing something, but when I run your example all I get is a sizable text edit window. No menu bar or menus
#5
Paste escaped. Lines must not begin with ;.
#6
I guess i was missing something :oops:

Thanks Big Grin
#7
Can a menu bar Dialog be encrypted?.

Function ( DialogWithMenu )
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

ret
;messages
sel message
,case WM_INITDIALOG
,
,case WM_SIZE
,RECT r; GetClientRect(hDlg &r)
,siz r.right r.bottom id(3 hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,;menu items:
,case 100 out "Save"
,case 101 out "Open"
,case 103 out "Cut"
,case 104 out "Select All"
,case 105 out "Help"
,
,case IDOK
,case IDCANCEL
ret 1

Function ( Call_Menubar )
Code:
Copy      Help
str DC=
;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x200 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""


str menubar=
;BEGIN MENU
;>&File

,;&Save : 100 0 0 Cs
,;&Open : 101 0 0 Co
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit

,;Cu&t : 103 0 0 Cx
,;-
,;Select &All : 104 0 0 Ca
,;<
;&Help : 105 0
;END MENU


str controls = "3"
str rea3
if(!ShowDialog(DC &DialogWithMenu &controls 0 2 0 0 0 0 0 "dialog.ico" menubar)) ret


output:
Code:
Copy      Help
Warning: cannot create or load menu BEGIN MENU
>&File
    &Save : 100 0 0 Cs
#8
I got it, had to take all the spaces out of the menu bar definitions.

Function ( Call_Menubar )
Code:
Copy      Help
str DC=
;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x200 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""


str menubar=
;BEGIN MENU
;>&File
;&Save : 100 0 0 Cs
;&Open : 101 0 0 Co
;-
;>&Recent
;Empty : 102 0 3
;<
;<
;>&Edit
;Cu&t : 103 0 0 Cx
;-
;Select &All : 104 0 0 Ca
;<
;&Help : 105 0
;END MENU


str controls = "3"
str rea3
if(!ShowDialog(DC &DialogWithMenu &controls 0 2 0 0 0 0 0 "dialog.ico" menubar)) ret
#9
I get this error

Error in DialogWithMenu: expected 0 to 10 arguments, not 12.


and it highlights ShowDialog
#10
Update your QM.
#11
It did not work because when you select multiple lines and right click the selection bar it inserts spaces after tabs. QM does it to make comments visually indented by one space even in lines that begin with tabs. It is not a multiline string because some lines begin with tabs. All lines must begin with spaces.

str s=
;this
;,is
;,a
;,multiline
;string

str s=
;this
,;is
,;not a
,;multiline
;string
#12
OK, i still get the argument error!
#13
Something wrong with your System folder. Try to delete System.qml file from qm folder and reinstall QM. Also check 'Always add System' in Options -> Files. Also don't use a UPC or other pp software. Don't know but they possibly install wrong System version.
#14
OK i reinstalled QM, is this code suppose to close QM?

Code:
Copy      Help
str DC=
;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 294 190 "Dialog"
;3 RichEdit20A 0x54233044 0x200 0 0 294 190 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2020009 "*" ""


str menubar=
;BEGIN MENU
;>&File
;&Save : 100 0 0 Cs
;&Open : 101 0 0 Co
;-
;>&Recent
;Empty : 102 0 3
;<
;<
;>&Edit
;Cu&t : 103 0 0 Cx
;-
;Select &All : 104 0 0 Ca
;<
;&Help : 105 0
;END MENU


str controls = "3"
str rea3
if(!ShowDialog(DC &Call_Menubar &controls 0 2 0 0 0 0 0 "dialog.ico" menubar)) ret



All it does is close QM.
#15
What is Call_Menubar?
#16
Not sure i just copied the code from above :?:
#17
OK i used Gint's example from above and it worked perfectly, Thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)