Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multipage dialog with menu (add/remove menu bar at run time)
#1
Is it possible to place DialogWithMenu on page 3 in a multipage dialog?

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

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

;Example of multipage dialog calling code:
;str controls = "3"
;str lb3
;lb3="&Page0[]Page1[]Page2"
;if(!ShowDialog("ThisFunction" &ThisFunction &controls)) ret
;...

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 4 4 96 80 ""
;1001 Static 0x54020000 0x4 106 4 48 13 "Page0"
;1101 Static 0x44020000 0x4 106 4 48 13 "Page1"
;1201 Static 0x44020000 0x4 106 4 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;5 Static 0x54000010 0x20004 4 138 258 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010200 "" "0"

ret
;messages
sel message
,case WM_INITDIALOG
,goto selectpage
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
ret 1
#2
I think this is what you were asking?

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

str controls = "3 1303"
str lb3 rea1303
lb3="&Page0[]Page1[]Page2[]Page3"
if(!ShowDialog("merged" &merged &controls  0 0 0 0 0 0 0 "" "merged")) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 0 0 96 80 ""
;1001 Static 0x54020000 0x4 106 4 48 13 "Page0"
;1101 Static 0x44020000 0x4 106 4 48 13 "Page1"
;1201 Static 0x44020000 0x4 106 4 48 13 "Page2"
;1301 Static 0x44020000 0x4 106 4 48 13 "Page3"
;1303 RichEdit20A 0x54233044 0x200 100 22 162 112 ""
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;5 Static 0x54000010 0x20004 4 138 255 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "3" ""

ret
;messages
sel message
,case WM_INITDIALOG
,goto selectpage
,case WM_DESTROY
,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
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
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

Or like so if you don't need the page control/don't need to go back from page 3:

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

str controls = "3 1303"
str lb3 rea1303
lb3="&Page0[]Page1[]Page2[]Page3"
if(!ShowDialog("merged" &merged &controls  0 0 0 0 0 0 0 "" "merged")) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 0 0 96 80 ""
;1001 Static 0x54020000 0x4 106 4 48 13 "Page0"
;1101 Static 0x44020000 0x4 106 4 48 13 "Page1"
;1201 Static 0x44020000 0x4 106 4 48 13 "Page2"
;1303 RichEdit20A 0x54233044 0x200 0 2 266 134 ""
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;5 Static 0x54000010 0x20004 4 138 253 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "3" ""

ret
;messages
sel message
,case WM_INITDIALOG
,goto selectpage
,case WM_DESTROY
,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
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
,if(_i = 3)
,,hid(id(3 hDlg))
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
#3
Thank You; I got that far. The problem is that the file edit and help menu needs to be on page 3 only and I do not know how to put it there.
#4
A window can have only 1 standard menu bar and it must be at the top. Child windows cannot have a menubar.

You can add/remove menu bar at run time:
Function Dialog38
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3"
str lb3
lb3="&Page0[]Page1[]Page2"
if(!ShowDialog("Dialog38" &Dialog38 &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 265 163 "Dialog"
;3 ListBox 0x54230101 0x204 4 4 96 80 ""
;1001 Static 0x54020000 0x4 106 4 48 13 "Page0"
;1101 Static 0x44020000 0x4 106 4 48 13 "Page1"
;1201 Static 0x44020000 0x4 106 4 48 13 "Page2"
;1 Button 0x54030001 0x4 142 146 48 14 "OK"
;2 Button 0x54030000 0x4 192 146 48 14 "Cancel"
;4 Button 0x54032000 0x4 242 146 18 14 "?"
;5 Static 0x54000010 0x20004 4 138 257 1 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030003 "" "0" ""

ret
;messages
sel message
,case WM_INITDIALOG
,goto selectpage
,case WM_DESTROY
,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
,case LBN_SELCHANGE<<16|3
,;selectpage
,_i=LB_SelectedItem(id(3 hDlg))
,DT_Page hDlg _i
,
,;add menu bar if page is 2, and remove in other pages
,int hmenu
,if(_i=2) hmenu=DT_CreateMenu("Dialog38")
,DT_SetMenu hDlg hmenu
,
ret 1

;BEGIN MENU
;>&File
,;&Open : 101 0
,;-
,;>&Recent
,,;Empty : 102 0 3
,,;<
,;<
;>&Edit
,;Cu&t[9]Ctrl+X : 103 0
,;-
,;Select &All : 104 0
,;<
;&Help : 105 0
;END MENU
#5
That is nice. I do not understand it completely yet but I will have fun learning.
Thank You


Forum Jump:


Users browsing this thread: 1 Guest(s)