Right Click Menu in a ListView.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Mario1776
Posts: 1
Joined: 26 Oct 2015, 19:31

Right Click Menu in a ListView.

21 Jun 2018, 18:23

I started with the example code Pulover pasted https://autohotkey.com/board/topic/8775 ... ntry557094 and it worked.
Then I named the gui window, and the right click no longer worked.
How to specify the GuiContextMenu to respond to the right click occurring in the named window?

Code: Select all

GoSub, CreateMain
Return

CreateMain:
; ADDED Window Naming
Gui, Main:New
Gui, Main:Add, ListView, Center vList, A1|A2|A3
Gui, Main:Show

; ADDED Filler Data
Loop, 4
{
	LV_Add("", A_Index, "Crap", "Mo Crap")
}

; Create a popup menu to be used as the context menu:
Menu, Main:MyContextMenu, Add, Action01, Edit
Menu, Main:MyContextMenu, Add, Action02, Edit
Return

GuiContextMenu:  ; Launched in response to a right-click or press of the Apps key.
if A_GuiControl <> List  ; Display the menu only for clicks inside the ListView.
    return
; Show the menu at the provided coordinates, A_GuiX and A_GuiY.  These should be used
; because they provide correct coordinates even if the user pressed the Apps key:
Menu, Main:MyContextMenu, Show, %A_GuiX%, %A_GuiY%
Return

Edit:
A1=xxx ;just an example
A2=xx1
B1=xx2
B2=xx3

Loop, 4
{
LV_Add(%A_index% Auto, A%A_Index%, B%A_Index%, C%A_Index%)
LV_ModifyCol(%A_index%,AutoHdr)
}
Return
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Right Click Menu in a ListView.

22 Jun 2018, 07:56

Hello Mario1776, just change

Code: Select all

GuiContextMenu:
by

Code: Select all

MainGuiContextMenu:
Donec Perficiam

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, lmstearn, roeleboele, ulysim and 376 guests