iAmNewbe

How Open Menu AND Right Align Menu Items?

2 posts in this topic

#1 ·  Posted (edited)

I have a menu and I want to be able to ALT + F and auto open the menu to display the items inside.

Below is the code I have been testing.  Can't get either the Alt + F to work to open the File Menu and the sub items hot key info is kind of all over the place instead of aligned to the right edge of the menu list how I want.





 

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>
Opt("GUIResizeMode", $GUI_DOCKAUTO)
Global $mainGUI = GUICreate("Test GUI", 985, 675, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP), BitOR($WS_EX_ACCEPTFILES,$WS_EX_CONTEXTHELP,$WS_EX_WINDOWEDGE))
Global $FileMenu = GUICtrlCreateMenu("&File")
Global $FileMenuOpen = GUICtrlCreateMenuItem("&Open" & "     Alt + O", $FileMenu)
GUICtrlSetStyle($FileMenuOpen, $SS_RIGHT)
Global $FileMenuSave = GUICtrlCreateMenuItem("&Save" & "     Alt + S", $FileMenu)
Global $FileMenuExport = GUICtrlCreateMenuItem("&Export" & "     Alt + E", $FileMenu)
Global $spacer = GUICtrlCreateMenuItem("", $FileMenu)
Global $FileMenuExit = GUICtrlCreateMenuItem("E&xit" & "     Alt + X", $FileMenu)
Global $mainGUI_AccelTable[7][2] = [["!f", $FileMenu], ["!o", $FileMenuOpen],["!e", $FileMenuExport],["!s", $FileMenuSave],["!x", $FileMenuExit],["{f4}", $FileMenuExit],["{ESC}", $FileMenuExit]]
GUISetAccelerators($mainGUI_AccelTable)
GUISetState(@SW_SHOW)


Func cw($str)
        ConsoleWrite($str&@crlf)
EndFunc

Func Quit()
    cw("Exit")
    Exit
EndFunc


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Quit()
        Case $FileMenu
            cw("File Menu")
            _GUICtrlMenu_SetItemEnabled($FileMenu, 1) ; <--- Does NOTHING in THIS situation
        Case $FileMenuOpen
            cw("Open File")
        Case $FileMenuSave
            cw("File Save")
        Case $FileMenuExport
            cw("File Export")
        Case $FileMenuExit
            Quit()
    EndSwitch
WEnd

 

Edited by iAmNewbe

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I used  

_GUICtrlMenu_SetItemEnabled

with assumption that would auto open the menu but it doesn't. I think it is meant to be used to just pre-select an item but in this case I was hoping it would open the menu when ALT + F is pressed.. nope..   Also double pressing ALT does not open the file menu like in other softwares...   I am doing something wrong, just not sure what. 

Edited by iAmNewbe

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