Sign in to follow this  
Followers 0
danielkza

Menu and Submenus question

2 posts in this topic

I have a menu that has submenus that must be hidden according to the selection of a listview.The Problem is: The root menu ($SkinMenu) never gets called in GuiGetMsg,and the items are not prepared correctly.

Does anybody know what can i do to solve this?

Gui Creation:

$SkinMenu = GUICtrlCreateMenu(GetLanguageString("MENU_SKIN_SKIN"))

$SkinAddMenuItem = GUICtrlCreateMenuItem(GetLanguageString("MENU_SKIN_ADD"), $SkinMenu)
$SkinEditMenuItem = GUICtrlCreateMenuItem(GetLanguageString("MENU_SKIN_EDIT"), $SkinMenu)
$SkinDeleteMenuItem = GUICtrlCreateMenuItem(GetLanguageString("MENU_SKIN_DELETE"), $SkinMenu)oÝ÷ غ(¤*y«­¢+Ù
ÍÀÌØíM­¥¹5¹Ô(%M­¥¹5¹ÕAÉÁÉ ¤)
ÍÀÌØíM­¥¹5¹Õ%Ñ´°ÀÌØíM­¥¹
½¹ÑáÑ5¹Õ%Ñ´(%M­¥¸ ¤)
ÍÀÌØíM­¥¹¥Ñ5¹Õ%Ñ´°ÀÌØíM­¥¹¥Ñ
½¹ÑáÑ5¹Õ%Ñ´(%¥ÑM­¥¸ ¤)
ÍÀÌØíM­¥¹±Ñ5¹Õ%Ñ´°ÀÌØíM­¥¹±Ñ
½¹ÑáÑ5¹Õ%Ñ´(%±ÑM­¥¸ ¤)
ÍÀÌØíM­¥¹=Á¹½±É
½¹ÑáÑ5¹Õ%Ñ´(%M¡±±áÕÑ ÀÌØí
ÕÉɹÑM­¥¹¥È¤oÝ÷ ØúÞ¥ªÚ¶*'
^jëh×6Func SkinMenuPrepare()
    If _GUICtrlListView_GetSelectedCount(GUICtrlGetHandle($SkinsList)) < 1 Then
        $State = $GUI_DISABLE
    Else
        $State = $GUI_ENABLE
    EndIf
    
    GUICtrlSetState($SkinDeleteMenuItem, $State)
    GUICtrlSetState($SkinEditMenuItem, $State)
    
    GUICtrlSetState($SkinEditContextMenuItem, $State)
    GUICtrlSetState($SkinDeleteContextMenuItem, $State)
    GUICtrlSetState($SkinOpenFolderContextMenuItem, $State)
EndFunc   ;==>SkinMenuPrepare

Share this post


Link to post
Share on other sites



Hi! Try this:

#include <GuiConstants.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>

Global Enum $idNew = 1000, $idOpen, $idSave

$hGUI = GUICreate("Test GUI", 300, 200)

$hFile = _GUICtrlMenu_CreateMenu()

_GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $idNew)
_GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $idOpen)
_GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $idSave)

$hMain = _GUICtrlMenu_CreateMenu()

_GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile)
_GUICtrlMenu_SetMenu($hGUI, $hMain)

GUIRegisterMsg($WM_INITMENU, "WM_INITMENU")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_INITMENU($hWnd, $Msg, $wParam, $lParam)
    
    If $wParam = $hMain Then ConsoleWrite("Main menu activated " & @LF)
    
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_INITMENU

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    
    Switch _WinAPI_LoWord ($wParam)
        Case $idNew
            ConsoleWrite("New" & @LF)
        Case $idOpen
            ConsoleWrite("Open" & @LF)
        Case $idSave
            ConsoleWrite("Save" & @LF)
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

:)

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  
Followers 0