So, here is the core of the code. It creates a listview, fills it with two lines and does something with double-click. With the context-menu (right-click) I want to extract the value of the clicked line - but I get nothing. Certainly I missed as usual a dot or a comma or something else ...
Code: Select all
#SingleInstance,Force
#NoEnv
; #NoTrayIcon
Gosub, ShowStartDialog
return
;; **********************************************************
;; **********************************************************
ShowStartDialog:
SS_REALSIZECONTROL := 0x40 ; erzwingt Grössenanpassung des Bildes in die Control
Gui, new,+HwndBundleList,Bundle Switcher
Gui -Resize -MaximizeBox Border ; ToolWindow
; Create the ListView and its columns:
Gui, Add, ListView, r20 w580 vMyListView gMyListView Grid , Icon|Name|Status|Description|Path|Picture
Gui, Add, Button, x+15 w70 Default , Quit ; xm puts it at the bottom left corner.
; Bundles durchsuchen, Liste aufbauen
; zaehler := 0
Gosub, ListBundle
; Create a popup menu to be used as the context menu:
Menu, MyContextMenu, Add, Go to folder, ContextGoToFolder
Menu, MyContextMenu, Add, Display Icon, ContextDisplayIcon
Gui , Show
OnMessage(0x200, "WM_MOUSEMOVE")
return
;;; **********************************************************
ListBundle:
Gosub, pruefung
; baue die Liste auf
if listeninhalt
{
Loop, Parse, listeninhalt, | ; zerhacke die Liste jeweils am Trennstrich
{ ;
StringSplit, zeileninhalt, A_LoopField,`t ; zerhacke den String an den Tabulatoren
LV_Add("Icon" . A_Index,,zeileninhalt1,zeileninhalt2,zeileninhalt3,zeileninhalt4,zeileninhalt5)
}
LV_ModifyCol(1, 30) ; icon
LV_ModifyCol(2, "Auto") ; Auto-size
LV_ModifyCol(3, 40) ; Status
LV_ModifyCol(3, "Text Center") ; Status
LV_ModifyCol(4, 350) ; Description
LV_ModifyCol(5, "Auto") ; Auto-size
LV_ModifyCol(6, 30) ; Iconpath
;LV_ModifyCol(3, "Text") ; For sorting, indicate that the Size column is an integer.
}
return
;;; **********************************************************
pruefung:
listeninhalt = name-a`tstatus-a`tbeschreibung-a`tc:\temp`ticon-a
listeninhalt = %listeninhalt%|name-b`tstatus`t-bbeschreibung`tC:\windows`ticon-b
return
;;; **********************************************************
MyListView:
fullpath :=
name :=
msgbox I am the doubelclick
return
;;; **********************************************************
GuiContextMenu: ; Launched in response to a right-click or press of the Apps key.
if A_GuiControl <> MyListView ; 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, MyContextMenu, Show, %A_GuiX%, %A_GuiY%
return
;;; **********************************************************
; zwei Routinen gemeinsam starten und dann erst aufteilen
ContextDisplayIcon: ; The user selected "DisplayIcon" in the context menu.
ContextGoToFolder: ; The user selected "GoToFolder" in the context menu.
; For simplicitly, operate upon only the focused row rather than all selected rows:
; FocusedRowNumber := LV_GetNext(0, "F") ; Find the focused row.
; MsgBox %FocusedRowNumber%
; if not FocusedRowNumber ; No row is focused.
; return
MsgBox %A_ThisMenuItem%
IfInString, A_ThisMenuItem, Display Icon ; User selected "DisplayIcon" from the context menu.
{
MsgBox a %FocusedRowNumber%
LV_GetText(name, A_EventInfo, 6)
Run %name%,, UseErrorLevel
}
else ; User selected "GoToFolder" from the context menu.
{
MsgBox b %FocusedRowNumber%
LV_GetText(name, A_EventInfo, 5)
Run %name%,, UseErrorLevel
}
msgbox %xname%
if ErrorLevel
MsgBox Could not perform requested action on %name%.
return
;; **********************************************************
ButtonQuit:
ExitApp