FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Menu with several windows
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Menu with several windows
Posted: Thu Mar 15, 2018 07:07 PM

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Menu with several windows
Posted: Wed Mar 21, 2018 11:06 AM

René,

You save each menu in a variable, like oMenu1, oMenu2, etc. then you do:

oMenuX:Activate()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Menu with several windows
Posted: Fri Mar 23, 2018 02:09 PM

Hello Antonio,

This simple command does the trick. Thanks

Kind regards,



René Koot
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Menu with several windows
Posted: Tue Apr 03, 2018 09:08 PM
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.
Code (fw): Select all Collapse
#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


Also the first MenuItem is always the name of the app, even if i write something different on that place.
Kind regards,



René Koot
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Menu with several windows
Posted: Tue Apr 10, 2018 02:05 PM
One solution ....

Code (fw): Select all Collapse
#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
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Menu with several windows
Posted: Tue Apr 10, 2018 07:04 PM

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.

Kind regards,



René Koot
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Menu with several windows
Posted: Thu Apr 12, 2018 09:11 PM

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

Continue the discussion