im using the main example of the listview doc to display a context menu.
i would like to know if it is possible to disable one or more contexts from the menu ?
example (cut,copy & undo disabled):
![Image](https://thumb.ibb.co/huYV45/menu2.jpg)
thanks.
Code: Select all
Gui Add, ListView, vMyListView w130 h80, Com1 | Com2
Gui Show,
LV_Add(,"word1","tiktak1")
LV_Add(,"word2","tiktak2")
LV_Add(,"word3","tiktak3")
FocusedRowNumber := LV_GetNext() ; Find the focused row.
LV_GetText(ID, FocusedRowNumber, 1) ; Get the text of the 1st field.
; Create a popup menu to be used as the context menu:
Menu, MyContextMenu, Add, %ID%, ContextOpen ; why i got Com1 instead the FocusedRowNumber which sould be word1, word2 or word3 ?
Menu, MyContextMenu, Add, show row number 1, ContextOpen2
Menu, MyContextMenu, Add, show row number 2, ContextOpen3
return
GuiContextMenu: ; Launched in response to a right-click
if A_GuiControl <> MyListView ; Display the menu only for clicks inside the ListView.
return
Menu, MyContextMenu, Show
return
ContextOpen:
return
ContextOpen2:
FocusedRowNumber := LV_GetNext() ; Find the focused row.
LV_GetText(ID, FocusedRowNumber, 1) ; Get the text of the 1st field.
MsgBox, %ID%
return
ContextOpen3:
FocusedRowNumber := LV_GetNext() ; Find the focused row.
LV_GetText(ID, FocusedRowNumber, 2) ; Get the text of the 2nd field.
MsgBox, %ID%
return
GuiEscape:
GuiClose:
ExitApp
wolf_II wrote:Try to check what the variable FocusedRowNumber contains, after you assign a value to it. It shows 0 for me.
I don't really understand the variation of the numbers 1,2 and 3 in your code?? I expect typos? (Menu open 2 -> get text from 1, ...)
Also, is this meant to be dynamic?
Code: Select all
Gui, -MinimizeBox
Gui Add, ListView, vMyListView w130 h80, Com1 | Com2
Gui Show,
LV_Add(,"word1","tiktak1")
LV_Add(,"word2","tiktak2")
LV_Add(,"word3","tiktak3")
Menu, MyContextMenu, Add,, ; Creates the menu so it can be deleted and re-built.
Return
GuiContextMenu: ; Launched in response to a right-click
if A_GuiControl <> MyListView ; Display the menu only for clicks inside the ListView.
return
LV_GetText(ID, A_EventInfo, 1) ; Get the text of the 1st field. -- A_EventInfo contains the row number right-clicked
Menu, MyContextMenu, DeleteAll ; Delete the entire menu
Menu, MyContextMenu, Add, %ID%, ContextOpen ; create the menu after getting the info.
Menu, MyContextMenu, Show
return
ContextOpen:
return
GuiEscape:
GuiClose:
ExitApp