Funkt leider nicht.
C
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListview.au3>
Global $sDBFile = @ScriptDir & '\produkte.txt'
Global $sHeader = 'Produkt-Bezeichnung|Produkt-ID|Version|Dat.Inst.|Lokation'
Global $aHeader = StringSplit($sHeader, '|') ; Überschriften-Array
Global $bSortSense = False
$Form1 = GUICreate("Installierte Produkte - Windows 7 32bit", 965, 250)
Global $idListView = GUICtrlCreateListView($sHeader, 0, 0, 965, 250)
Global $hListView = GUICtrlGetHandle($idListView)
_GUICtrlListView_SetColumnWidth($idListView, 0, 330)
_GUICtrlListView_SetColumnWidth($idListView, 1, 50)
_GUICtrlListView_SetColumnWidth($idListView, 2, 50)
_GUICtrlListView_SetColumnWidth($idListView, 3, 50)
_GUICtrlListView_SetColumnWidth($idListView, 4, 400)
_GUICtrlListView_RegisterSortCallBack($idListView)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
If FileExists($sDBFile) Then Load()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $idListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
_GUICtrlListView_SimpleSort($hWndListView, $g_bSortSense, DllStructGetData($tNMHDR, "SubItem"))
EndSwitch
EndSwitch
WEnd
Func Load()
Local $hFile, $sContent, $aNewItems
$hFile = FileOpen($sDBFile, 0)
If $hFile <> -1 Then
$sContent = FileRead($hFile)
FileClose($hFile) ; Datei schließen
$sContent = StringTrimRight($sContent, 2)
$aNewItems = StringSplit($sContent, @CRLF, 1)
If Not IsArray($aNewItems) Then Return
_GUICtrlListView_BeginUpdate($hListView)
For $i = 1 To $aNewItems[0]
GUICtrlCreateListViewItem($aNewItems[$i], $idListView)
Next
_GUICtrlListView_EndUpdate($hListView)
EndIf
EndFunc
Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam
Local $tNMHDR = DllStructCreate($tagNMLISTVIEW, $lParam)
Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
Local $iCode = DllStructGetData($tNMHDR, "Code")
Static Local $g_bSortSense = True
If (_WinAPI_GetClassName($hWndFrom) = "SysListView32") and ($iCode = $LVN_COLUMNCLICK) Then
_GUICtrlListView_SimpleSort($hWndFrom, $g_bSortSense, DllStructGetData($tNMHDR, "SubItem"))
EndIf
Return $GUI_RUNDEFMSG
EndFunc
Alles anzeigen
Line 35
Switch $iCode
Switch ^ ERROR
Error: Variable used without being declared