Jump to content
Sign in to follow this  
_Vlad

How to create 2 main menus

Recommended Posts

Hello AutoIt,

I'm new around here and I need help understanding GUICtrlCreateMenu function.

I tried to implement 2 different Main Menus, one below other, like a submenu, but I can see that in the script it only allows me to create one.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("2 MainMenus", 615, 137, 192, 124)
$MenuItem1 = GUICtrlCreateMenu("MainMenu 1")

;How to make 2 different menus? One below other?

GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Any suggestions?

Regards, :)


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

Hello aspectulconteazz, welcome to the forums.

 

I recommend that you check out: GUICtrlCreateMenuItem from the help file. I think that this is what you're looking for. If it's not, can you explain more on what you're looking for? Or a screenshot example of something else that's similar.

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("2 MainMenus", 615, 137, 192, 124)
$MenuItem1 = GUICtrlCreateMenu("MainMenu 1")
$Menu1Sub1 = GUICtrlCreateMenuItem('SubMenu1', $MenuItem1)
$Menu1Sub2 = GUICtrlCreateMenuItem('SubMenu2', $MenuItem1)

$MenuItem2 = GUICtrlCreateMenu("MainMenu 2")
$Menu2Sub1 = GUICtrlCreateMenuItem('SubMenu1', $MenuItem2)
$Menu2Sub2 = GUICtrlCreateMenuItem('SubMenu2', $MenuItem2)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Menu1Sub1
            ConsoleWrite(':' & @ScriptLineNumber & ': - Menu 1, Sub 1 clicked' & @CRLF)

        Case $Menu1Sub2
            ConsoleWrite(':' & @ScriptLineNumber & ': - Menu 1, Sub 2 clicked' & @CRLF)

        Case $Menu2Sub1
            ConsoleWrite(':' & @ScriptLineNumber & ': - Menu 2, Sub 1 clicked' & @CRLF)

        Case $Menu2Sub2
            ConsoleWrite(':' & @ScriptLineNumber & ': - Menu 2, Sub 2 clicked' & @CRLF)

    EndSwitch
WEnd

I added a couple menu items to your example code, and cases for them into the main loop. It'll display in the SciTE console when you click on one of the MenuItems. You can replace the ConsoleWrite with whatever you want to have happen.


RAWR! I'm hungry :( Feed the panda squirrle

Share this post


Link to post
Share on other sites

Hello,

After many days still didn't solved the problem.

 

What I meant is that I want to create a whole menu bar and below that other bar.

For example bar number 1 to have 'File', 'Settings' with subitems and bar number 2 to be under the number 1 bar and have other main menu items.

 

Regards,


Quote
Destiny is a name often given in retrospect to choices that had dramatic consequences.  J.K. Rowling

 

Share this post


Link to post
Share on other sites

as far as i'm aware, you can only have one menu bar.  Maybe you could create a child window with it's own menu and embed it within your main GUI?

 


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...