I want to solve the problem, illustrated in attached code.
When I link the childwindow inside the main window the menubar of the child disappear.
I have attached the code, project and exe file to illustrate the behavior.
Look at this code sample:
#Include 'dcdialog.ch'
#include 'appevent.ch'
PROCEDURE Main()
LOCAL GetList := {}, oFileMenu, oFilemenu1, oFilemenu2, oMenuBar, oEditMenu,;
oMemo, oUtilMenu, lok := .t.
Local odlg
/* ---- Menu ---- */
DCMENUBAR oMenuBar parent oDlg ;
ownerdraw ;
menubarcolor 0,{150,150,150};
subbarcolor 1,{150,150,150} ;
subcolor 0,{200,200,200}
DCSUBMENU oFileMenu PROMPT "&Menu" ;
checked ;
PARENT oMenuBar
DCMENUITEM "Test with menu" PARENT oFileMenu ;
accelkey xbeK_ALT_F4 ;
ACTION {||test('menu',odlg)}
DCMENUITEM "Test without menu" PARENT oFileMenu ;
accelkey xbeK_ALT_F4 ;
ACTION {||test('',odlg)}
DCMENUITEM "E&xit Alt-F4" PARENT oFileMenu ;
accelkey xbeK_ALT_F4 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
dcread gui parent @odlg title 'Main window'
return
procedure test(parm,odlg)
Local cString := space(30)
LOCAL GetList := {}
Local oFileMenu,oMenuBar
local odlg1
setAppwindow(odlg:drawingarea)
DCMENUBAR oMenuBar parent oDlg1 ;
menubarcolor 0,{150,150,150};
subbarcolor 1,{150,150,150} ;
subcolor 0,{200,200,200}
DCSUBMENU oFileMenu PROMPT "&Menu" ;
checked ;
PARENT oMenuBar
DCMENUITEM "E&xit Alt-F4" PARENT oFileMenu ;
accelkey xbeK_ALT_F4 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
@ 1,1 dcsay 'String' get cString
dcgetoptions autowinmenu eval{||setappwindow(odlg:drawingarea)}
if parm = 'menu'
dcRead gui fit buttons 1 options getoptions parent @odlg1 //Menu visible
else
dcRead gui fit buttons 1 parent @odlg1 options getoptions appwindow @odlg //Menu invisible
endif
RETURN
procedure appsys()
return
Menubar in linked childwindows
-
- Posts: 8
- Joined: Mon Feb 08, 2010 11:13 am
Menubar in linked childwindows
- Attachments
-
- Menutest.zip
- (8.39 KiB) Downloaded 831 times
Re: Menubar in linked childwindows
Your problem is due to a limitation of Windows.
It does not allow more than 1 menubar in an application with child windows.
This is why it works when the window is a child of the desktop but not the main window.
I have modified your code to show how you can still use DCSUBMENU and DCMENUITEM commands to build a menu structure but the menubar will be replaced with a DCSTATUSBAR, DCTOOLBAR and DCADDBUTTONs.
If there are other eXpress++ users who would like to have a menu structure on child windows, I would consider writing a new eXpress++ command that would simplify the code to do this.
Something maybe like this. It would automatically create the toolbar and buttons. :
Here is your modified code:
It does not allow more than 1 menubar in an application with child windows.
This is why it works when the window is a child of the desktop but not the main window.
I have modified your code to show how you can still use DCSUBMENU and DCMENUITEM commands to build a menu structure but the menubar will be replaced with a DCSTATUSBAR, DCTOOLBAR and DCADDBUTTONs.
If there are other eXpress++ users who would like to have a menu structure on child windows, I would consider writing a new eXpress++ command that would simplify the code to do this.
Something maybe like this. It would automatically create the toolbar and buttons. :
Code: Select all
DCSTATUSBARMENU oMenuBar
DCSUBMENU oFileMenu PROMPT 'Menu'
DCMENUITEM 'Exit' PARENT oFileMenu
Code: Select all
procedure test(parm,odlg)
Local cString := space(30)
LOCAL GetList := {}
Local oFileMenu,oMenuBar,oFileMenu2
local odlg1
LOCAL oStatTop, oToolbar
// setAppwindow(odlg:drawingarea)
DCSTATUSBAR oStatTop HEIGHT 20 ALIGN DCGUI_ALIGN_TOP
@ 0,0 DCTOOLBAR oToolBar PARENT oStatTop SIZE 300,15 PIXEL ;
BUTTONSIZE 60,15 COLOR nil, GRA_CLR_PALEGRAY
/*
DCMENUBAR oMenuBar parent oDlg1 ;
menubarcolor 0,{150,150,150};
subbarcolor 1,{150,150,150} ;
subcolor 0,{200,200,200}
*/
DCADDBUTTONXP CAPTION 'Menu' ;
PARENT oToolBar ;
COLOR nil, GRA_CLR_PALEGRAY ;
ACTION {|a,b,o|oFileMenu:PopUp( o:setParent(), o:currentPos(), 2 , ;
XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) } ;
DCSUBMENU oFileMenu PROMPT "&Menu" ;
checked ;
DCMENUITEM "E&xit Alt-F4" PARENT oFileMenu ;
accelkey xbeK_ALT_F4 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
DCADDBUTTONXP CAPTION 'Menu 2' ;
PARENT oToolBar ;
COLOR nil, GRA_CLR_PALEGRAY ;
ACTION {|a,b,o|oFileMenu2:PopUp( o:setParent(), o:currentPos(), 2 , ;
XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) } ;
DCSUBMENU oFileMenu2 PROMPT "&Menu 2" ;
checked ;
DCMENUITEM "E&xit Alt-F4" PARENT oFileMenu2 ;
accelkey xbeK_ALT_F4 ;
ACTION {||DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList)}
@ 1,1 dcsay 'String' get cString
dcgetoptions ;
;// autowinmenu ;
;// eval{||setappwindow(odlg:drawingarea)}
if parm = 'menu'
dcRead gui fit buttons 1 ;
options getoptions ;
parent @odlg1
else
dcRead gui fit buttons 1 ;
;// parent @odlg1 ;
options getoptions ;
appwindow odlg:drawingArea
endif
RETURN
- Attachments
-
- menutest.zip
- Modified menu test program
- (21.73 KiB) Downloaded 854 times
The eXpress train is coming - and it has more cars.
-
- Posts: 8
- Joined: Mon Feb 08, 2010 11:13 am
Re: Menubar in linked childwindows
Thank you, this will solve my problem.