Menu with several windows
- plantenkennis
- Posts: 151
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Menu with several windows
In my main window I have a menu that is visible at the top of my screen. When I create another window in my program I can set a menu for this window, which replaced the first menu. But when I close the second window, how do I get my first menu visible again.
Kind regards,
René Koot
René Koot
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Menu with several windows
René,
You save each menu in a variable, like oMenu1, oMenu2, etc. then you do:
oMenuX:Activate()
You save each menu in a variable, like oMenu1, oMenu2, etc. then you do:
oMenuX:Activate()
- plantenkennis
- Posts: 151
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Re: Menu with several windows
Hello Antonio,
This simple command does the trick. Thanks
This simple command does the trick. Thanks
Kind regards,
René Koot
René Koot
- plantenkennis
- Posts: 151
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Re: Menu with several windows
Hello Antonio,
I was playing around with the menu again, but can't get it to work. I can set a new menu with a new window or diolog, but nothing happens when I click on a menuitem. I have created a little sample.
Also the first MenuItem is always the name of the app, even if i write something different on that place.
I was playing around with the menu again, but can't get it to work. I can set a new menu with a new window or diolog, but nothing happens when I click on a menuitem. I have created a little sample.
Code: Select all
#include "FiveMac.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
BuildMenu()
DEFINE WINDOW oWnd TITLE "Hello world"
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Want to end ?" )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Files" && in menu this gives 'testmenu'
MENU
MENUITEM "New..."
MENUITEM "Open..." ACTION New_Window()
SEPARATOR
MENUITEM "Exit..." ACTION oWnd:End()
ENDMENU
MENUITEM "Help"
MENU
MENUITEM "Wiki..."
MENUITEM "About..." ACTION MsgAbout( "(C) FiveTech Software 2012", "FiveMac" )
ENDMENU
ENDMENU
return oMenu
//----------------------------------------------------------------------------//
function New_Window()
local oDlg, oMenuDlg
DEFINE DIALOG oDlg
BuildMenuDlg()
ACTIVATE DIALOG oDlg
return nil
//----------------------------------------------------------------------------//
function BuildMenuDlg()
local oMenuDlg
MENU oMenuDlg
MENUITEM 'Dialog'
MENU
MENUITEM "help" ACTION MsgAbout( "Do we see this", "Test" )
ENDMENU
MENUITEM 'Test me'
MENU
MENUITEM "Click on me!" ACTION MsgInfo('show me')
ENDMENU
ENDMENU
return oMenuDlg
Kind regards,
René Koot
René Koot
Re: Menu with several windows
One solution ....
Code: Select all
#include "FiveMac.ch"
static oWnd
static MenuParent
//----------------------------------------------------------------------------//
function Main()
BuildMenu()
DEFINE WINDOW oWnd TITLE "Hello world"
ACTIVATE WINDOW oWnd ;
VALID MsgYesNo( "Want to end ?" )
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
MENU MenuParent
MENUITEM "Files" && in menu this gives 'testmenu'
MENU
MENUITEM "New..."
MENUITEM "Open..." ACTION New_Window()
SEPARATOR
MENUITEM "Exit..." ACTION oWnd:End()
ENDMENU
MENUITEM "Help"
MENU
MENUITEM "Wiki..."
MENUITEM "About..." ACTION MsgAbout( "(C) FiveTech Software 2012", "FiveMac" )
ENDMENU
ENDMENU
return MenuParent
//----------------------------------------------------------------------------//
function New_Window()
local oDlg, oMenuDlg
DEFINE DIALOG oDlg
BuildMenuDlg()
ACTIVATE DIALOG oDlg ;
VALID ( MenuParent:activate(),.t. )
return nil
//----------------------------------------------------------------------------//
function BuildMenuDlg()
local oMenuDlg
MENU oMenuDlg
MENUITEM 'Dialog'
MENU
MENUITEM "help" ACTION MsgAbout( "Do we see this", "Test" )
ENDMENU
MENUITEM 'Test me'
MENU
MENUITEM "Click on me!" ACTION MsgInfo('show me')
ENDMENU
ENDMENU
return oMenuDlg
- plantenkennis
- Posts: 151
- Joined: Wed Nov 25, 2015 7:13 pm
- Location: the Netherlands
- Contact:
Re: Menu with several windows
Hello Mastintin,
Thank you for this sample, but it changes nothing to the problem I have. If you open the New window/dialog the oMenuDlg comes at the top, but nothing happens if you click one of the items (like 'help' or 'click on me'.
I think I will work with icons oon all my dialog windows to activate actions.
Thank you for this sample, but it changes nothing to the problem I have. If you open the New window/dialog the oMenuDlg comes at the top, but nothing happens if you click one of the items (like 'help' or 'click on me'.
I think I will work with icons oon all my dialog windows to activate actions.
Kind regards,
René Koot
René Koot
Re: Menu with several windows
I have reviewed the code of the menu class and made some changes so that you can switch between the menus you want only by activating them.
The Menus on Mac belong to the application and not to the windows, so it is up to the programmer to exchange them as needed.
You can also include images in them.
Soon it will be ready ...
Regards
The Menus on Mac belong to the application and not to the windows, so it is up to the programmer to exchange them as needed.
You can also include images in them.
Soon it will be ready ...
Regards