Hallo,
ist es möglich ein ContextMenu auf bestimmte ListviewItems zu setzen und dann zu sehen auf welchem es angewendet wurde?
Wenn ja, wie?
mfg Freaky
ContextMenu bei ListviewItems?
-
- [ offen ]
-
Freaky -
22. Oktober 2012 um 01:35 -
Geschlossen -
Erledigt
-
-
Ich hab das bei mir so (auszugsweise):
[autoit]...
[/autoit]
Global $LVUsers = GUICtrlCreateListView("Login|Vollständiger Name|Beschreibung|Telefon", 20, 43, $win_w / 2 , $win_h - 140, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
; Kontextmenu erstellen
Global $aUContext[7] = ["Laufwerksgröße H","Laufwerksgröße P","ins H-LW", _
"ins P-LW", "entsperren","PW ändern", "Rechte ändern"]
Global $aUContextI[7]
Global $UHelpContext = GUICtrlCreateContextMenu($LVUsers)
For $i = 0 to UBound($aUContext) -1
$aUContextI[$i] = GUICtrlCreateMenuItem($aUContext[$i], $UHelpContext)
GUICtrlCreateMenuItem("", $UHelpContext) ; separator
Next
...
[autoit]
in der While-Schleife:
[/autoit]
...
Global $nMsg = GUIGetMsg(1)
...
For $i = 0 To UBound($aUContextI) - 1
If $nmsg[0] = $aUContextI[$i] Then
$iBenutzername = _GUICtrlListView_GetItemText($LVUsers, _GUICtrlListView_GetSelectionMark($LVUsers),0)
ContextU($i); auf das gewählte Context-Item reagieren..
EndIf
Next
...und wenn bestimmte kein Context bekommen sollen, kann man ja oben abfragen usw..
-
- Offizieller Beitrag
Oder du verwendest meine OwnContext UDF.
-
Hallo Freaky,
hier mal ein klenes Beispiel:
Spoiler anzeigen
[autoit]#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
;#include <array.au3>$main = GUICreate("Testlistview Drag & Drop from LV to Input and ContextMenu", 600, 400)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$idLV_Filme = GUICtrlCreateListView("Name| Länge|Bemrkung", 10, 10, 580, 350, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS ), BitOR($LVS_EX_FULLROWSELECT, $WS_EX_CLIENTEDGE))$idInpTarget = GUICtrlCreateInput("Target", 10, 370, 500, 20)
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetState($idInpTarget, $GUI_DROPACCEPTED)
For $i = 1 To 19
GUICtrlCreateListViewItem("Filmname" & $i & " |" & Random(45, 190,1)&":" & Random(0,59,1) & "|" & "Bem " & $i , $idLV_Filme)
Next
$idHC_LV = GUICtrlCreateContextMenu($idLV_Filme)
$idHC_ItemInfo = GUICtrlCreateMenuItem("Item-Info", $idHC_LV)
_GUICtrlListView_SetColumnWidth($idLV_Filme,0,200)
GUISetState()
$first = True
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_DROPPED
;$aItem = _GUICtrlListView_GetItemText($idLV_Filme)
;_ArrayDisplay($aItem)
$sItem = _GUICtrlListView_GetItemTextString($idLV_Filme)
GUICtrlSetData($idInpTarget,$sItem)
Case $idHC_ItemInfo
$aItem = _GUICtrlListView_GetItemTextArray($idLV_Filme)
MsgBox(0, $aItem[1], $aItem[2])
;die 1. Spalte als MsgBoxüberchrift
;die 2. Spalte als MsgBoxtext
ConsoleWrite($aItem[3] & @crlf)
;die 3. Spalte als ConsolenausgabeCase $GUI_EVENT_CLOSE
[/autoit]
Exit
EndSwitch
WEndmfg autoBert
-
Vielen Dank, ich hätte mir das viel komplizierter vorgestellt