Jump to content
Sign in to follow this  
zackrspv

[RESOLVED] Menu Items

Recommended Posts

zackrspv

I have this code:

Global Enum $idMenuClose = 1000, $idEscalate;- Create a custom message code for this function
$hMenu = _GUICtrlMenu_CreatePopup();- create a menu popup
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "Close/Transfer Ticket", $idMenuClose);- add item to created menu
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "Escalate Cal", $idEscalate)

The problem is that, while I can see both menu options, if i left click on the 2nd menu option, the menu comes back and i have to click on the 2nd option again.

How can i fix that?

Note get this problem on Beta and Release

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
MikeP

Hi.. can't reproduce your error.. I took the example from the Help file and mixed with your stuff and :

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

Opt('MustDeclareVars', 1)

Global Enum $idOpen = 1000, $idSave, $idInfo
Global Enum $idMenuClose = 1000, $idEscalate


_Main()

Func _Main()
Local $hGUI

    ; Create GUI
    $hGUI = GUICreate("Menu", 400, 300)
    GUISetState()


    ; Register message handlers
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
    GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU")

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>_Main

; Handle WM_COMMAND messages
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Switch $iwParam
        Case $idMenuClose
            _WinAPI_ShowMsg ("Close/Transfer Ticket")
        Case $idEscalate
            _WinAPI_ShowMsg ("Escalate Cal")
    EndSwitch
EndFunc   ;==>WM_COMMAND

; Handle WM_CONTEXTMENU messages
Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hMenu

    $hMenu = _GUICtrlMenu_CreatePopup ()
   _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Close/Transfer Ticket", $idMenuClose)
    _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Escalate Cal", $idEscalate)
    _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam)
    _GUICtrlMenu_DestroyMenu ($hMenu)
    Return True
EndFunc   ;==>WM_CONTEXTMENU

...working. No idea where's your issue.

Share this post


Link to post
Share on other sites
zackrspv

Hi.. can't reproduce your error..

...working. No idea where's your issue.

Well, simple fact is that it IS happening to me, unfortunatly.

Here's the code at the very top of my script (after the includes and such):

Global Enum $idMenuClose = 1000, $idEscalate;- Create a custom message code for this function
$hMenu = _GUICtrlMenu_CreatePopup();- create a menu popup
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "Close/Transfer Ticket", $idMenuClose);- add item to created menu
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "Escalate Cal", $idEscalate)

And here's the WM_Notify Relevant section:

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $MyTicketList
    If Not IsHWnd($MyTicketList) Then $hWndListView = GUICtrlGetHandle($MyTicketList)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $MyTicketList
            Switch $iCode
                Case $NM_RCLICK; Sent by a list-view control when the user clicks an item with the right mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $ticketindex = _GUICtrlListView_GetSelectedIndices($MyTicketList, True)
                    $ticketindex2 = _GUICtrlListView_GetSelectedIndices($MyTicketList, False)
                    If $ticketindex2 = "" Then
                    Else
                        If _GUICtrlMenu_TrackPopupMenu($hMenu, $MyTicketList, -1, -1, 1, 1, 2) = $idMenuClose Then
                            $crTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                            $crTicketID = $crTicketID[3]
                            ConsoleWrite("crTicketID: " & $crTicketID & @CRLF)
                            $CRmsg = "Ok"
                            
                        ElseIf _GUICtrlMenu_TrackPopupMenu($hMenu, $MyTicketList, -1, -1, 1, 1, 2) = $idEscalate Then
                            $erTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                            $erTicketID = $erTicketID[3]
                            ConsoleWrite("erTicketID: " & $erTicketID & @CRLF)
                            $ERmsg = "Ok"
                            
                        EndIf
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc;==>WM_NOTIFY

Ha, you may have to fix that func to work prorperly, may be too many endswitches for you, had to cut and paste information to sanitize it for here, so may have messed up my cut and paste. But, rest assured, i get no errors on my end for even beta side.

Autoit Versions:

Production: 3.2.10.0

Beta: 3.2.11.10

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
zackrspv

Well, simple fact is that it IS happening to me, unfortunatly.

Here's the code at the very top of my script (after the includes and such):

Global Enum $idMenuClose = 1000, $idEscalate;- Create a custom message code for this function
$hMenu = _GUICtrlMenu_CreatePopup();- create a menu popup
_GUICtrlMenu_InsertMenuItem($hMenu, 0, "Close/Transfer Ticket", $idMenuClose);- add item to created menu
_GUICtrlMenu_InsertMenuItem($hMenu, 1, "Escalate Cal", $idEscalate)

And here's the WM_Notify Relevant section:

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $MyTicketList
    If Not IsHWnd($MyTicketList) Then $hWndListView = GUICtrlGetHandle($MyTicketList)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $MyTicketList
            Switch $iCode
                Case $NM_RCLICK; Sent by a list-view control when the user clicks an item with the right mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $ticketindex = _GUICtrlListView_GetSelectedIndices($MyTicketList, True)
                    $ticketindex2 = _GUICtrlListView_GetSelectedIndices($MyTicketList, False)
                    If $ticketindex2 = "" Then
                    Else
                        If _GUICtrlMenu_TrackPopupMenu($hMenu, $MyTicketList, -1, -1, 1, 1, 2) = $idMenuClose Then
                            $crTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                            $crTicketID = $crTicketID[3]
                            ConsoleWrite("crTicketID: " & $crTicketID & @CRLF)
                            $CRmsg = "Ok"
                            
                        ElseIf _GUICtrlMenu_TrackPopupMenu($hMenu, $MyTicketList, -1, -1, 1, 1, 2) = $idEscalate Then
                            $erTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                            $erTicketID = $erTicketID[3]
                            ConsoleWrite("erTicketID: " & $erTicketID & @CRLF)
                            $ERmsg = "Ok"
                            
                        EndIf
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc;==>WM_NOTIFY

Ha, you may have to fix that func to work prorperly, may be too many endswitches for you, had to cut and paste information to sanitize it for here, so may have messed up my cut and paste. But, rest assured, i get no errors on my end for even beta side.

Autoit Versions:

Production: 3.2.10.0

Beta: 3.2.11.10

Issue resolved, just used switch on the trackpopup command:

Case $NM_RCLICK; Sent by a list-view control when the user clicks an item with the right mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $ticketindex = _GUICtrlListView_GetSelectedIndices($MyTicketList, True)
                    $ticketindex2 = _GUICtrlListView_GetSelectedIndices($MyTicketList, False)
                    If $ticketindex2 = "" Then
                    Else
                        Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $MyTicketList, -1, -1, 1, 1, 2)
                            Case $idMenuClose
                                $crTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                                $crTicketID = $crTicketID[3]
                                ConsoleWrite("crTicketID: " & $crTicketID & @CRLF)
                                $CRmsg = "Ok"
                                
                            Case $idEscalate
                                $erTicketID = _GUICtrlListView_GetItem($MyTicketList, $ticketindex[1])
                                $erTicketID = $erTicketID[3]
                                ConsoleWrite("erTicketID: " & $erTicketID & @CRLF)
                                $ERmsg = "Ok"
                                
                        EndSwitch
                    EndIf

Now, it properly registers both commands.


-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

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  

×