CygnusX1

_GUICtrlMenu_GetItemEnabled inconsistent results

4 posts in this topic

#1 ·  Posted (edited)

Hey, 

I'm trying to determine whether a menu item is enabled or not. _GUICtrlMenu_GetItemEnabled is returning inconsistent results. It returns True when a menu item is clearly grayed/disable. Actually, all of the menu functions are inconsistent _GUICtrlMenu_GetItemGrayed, _GUICtrlMenu_GetItemState, _GUICtrlMenu_GetItemDisabled, etc...

My function looks like this, maybe it's me.

Func FileExportMenuState()
    NewModel()
    $sSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, 0)
    $sSubSubMenu = _GUICtrlMenu_GetItemSubMenu($sSubMenu, 15)
    $iCount = _GUICtrlMenu_GetItemCount($sSubSubMenu)
    $sActual = ""
    For $x = 0 To $iCount - 1
        $sType = _GUICtrlMenu_GetItemType($sSubSubMenu, $x)
        If $sType <> 2048 Then
            $sActual = $sActual & _GUICtrlMenu_GetItemEnabled($sSubSubMenu, $x)
            $sText = _GUICtrlMenu_GetItemText($sSubSubMenu, $x)
;~          ConsoleWrite($sText & @CRLF)
        EndIf
    Next
    Sleep(1000)
;~  ConsoleWrite($sActual & @CRLF)
    Assert("FileExportMenuState() ", $sFileExportMenuStatus, $sActual)
EndFunc   ;==>FileExportMenuState

_GUICtrlMenu_GetItemEnabled is returning True for all 4 of the menu items in the Export flyout in the attached image.

Any help would be appreciated. 

Brad

menu.jpg

Edited by CygnusX1
Added image and more text

Cygnus

Share this post


Link to post
Share on other sites



#2 ·  Posted

Very often, the menu items change state when you call the menu. Try to get the status of the item when the menu is displayed.

Share this post


Link to post
Share on other sites

#3 ·  Posted

That was actually what the problem! Thank you!

At the beginning of my script I'm invoking all the menus to be displayed for a split second and now it is working great.

Thanks again.

Brad


Cygnus

Share this post


Link to post
Share on other sites

#4 ·  Posted

Ok, I thought it was solved but it isn't. I adjusted the script to open the menu while I'm getting the menu state. 

The video clearly shows a menu is grayed and the state of the menu is being returned as enabled. The opposite is also true, some active menus are being returned as not enabled. 

Any thoughts as to what is going on?

Thank you,

Brad

menus.mp4


Cygnus

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