Hallo Leute ich hab ein rießiges Problem...
Ich hab gestern ca 3 stunden verbracht dieses Skript hier zu machen:
Spoiler anzeigen
#include
#include
#include
#include
#include
#include
Global $Pfad, $Drive, $aDrives, $acPfad = '', $arDrives[1]
$hImage = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImage, 'shell32.dll', 3) ;0 Verzeichnis-Icon
_GUIImageList_AddIcon($hImage, 'shell32.dll', 1) ;1 Datei-Icon
_GUIImageList_AddIcon($hImage, 'shell32.dll', 5) ;2 Diskette
_GUIImageList_AddIcon($hImage, 'shell32.dll', 7) ;3 Wechseldatenträger
_GUIImageList_AddIcon($hImage, 'shell32.dll',
;4 Festplatte
_GUIImageList_AddIcon($hImage, 'shell32.dll', 11) ;5 CDROM
_GUIImageList_AddIcon($hImage, 'shell32.dll', 12) ;6 Netzwerklaufwerk
_GUIImageList_AddIcon($hImage, 'shell32.dll', 53) ;7 Unbekannt
_GUIImageList_AddIcon($hImage, 'shell32.dll', 110) ;8 Verzeichnis-Icon mit Haken
$Form1 = GUICreate("listview items", 375, 350, 100, 200, -1, $WS_EX_ACCEPTFILES)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$T6_List1 = _GUICtrlListView_Create($Form1, "", 0, 30, 375, 320)
_GUICtrlListView_SetImageList($T6_List1, $hImage, 1)
_GUICtrlListView_InsertColumn($T6_List1, 0, "Name", 10)
_GUICtrlListView_InsertColumn($T6_List1, 1, "Größe", 120)
_GUICtrlListView_InsertColumn($T6_List1, 2, "Typ", 75)
_GUICtrlListView_SetColumnWidth($T6_List1, 0, 120)
_GUICtrlListView_SetColumnWidth($T6_List1, 1, 120)
_GUICtrlListView_SetColumnWidth($T6_List1, 2, 75)
$T6_Label1 = GUICtrlCreateLabel("Pfad: Computer", 5, 5, 370, 20)
[/autoit] [autoit][/autoit] [autoit]_FileExplorer(0)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$nmsg = GUIGetMsg()
Switch $nmsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _FileExplorer2()
Local $iDrive = 0
$listread = StringSplit(_GUICtrlListView_GetItemTextString($T6_List1), "|")
If $listread[1] = "" Then
MsgBox(0, "nichts ausgewählt", "")
Else
If StringRight($listread[1], 1) = "\" Then
$acPfad &= $listread[1]
_FileExplorer(1, $listread[1])
ElseIf $listread[1] = ".." Then
For $i = 1 To UBound($arDrives) - 1
If StringUpper($arDrives[$i])&"\" = $acPfad Then
$iDrive = 1
_FileExplorer(0)
ExitLoop
EndIf
Next
If $iDrive = 0 Then
$split = StringSplit($acPfad, "\")
$acPfad = StringTrimRight($acPfad, StringLen($split[$split[0] - 1]) + 1)
_FileExplorer(1, $acPfad)
EndIf
Else
;MsgBox(0, "", $acPfad & $listread[1])
ShellExecute($acPfad & $listread[1])
EndIf
EndIf
EndFunc ;==>_FileExplorer2
Func _FileExplorer($Mode, $Pfad = 0)
_GUICtrlListView_DeleteAllItems($T6_List1)
Local $Indes, $iLWindex
Global $aDrives
Switch $Mode
Case 0
$acPfad = ''
GUICtrlSetData($T6_Label1, "Pfad: Computer")
$aDrives = DriveGetDrive('ALL')
For $i = 1 To $aDrives[0]
$iLWindex = 0
Switch DriveGetType($aDrives[$i])
Case 'Fixed'
$iLWindex = 4
Case 'CDROM'
$iLWindex = 5
Case 'RAMDisk'
$iLWindex = 6
Case 'Removable'
$iLWindex = 3
If StringLeft($aDrives[$i], 2) = 'a:' Or StringLeft($aDrives[$i], 2) = 'b:' Then $iLWindex = 2
Case Else
$iLWindex = 8
EndSwitch
_ArrayAdd($arDrives, $aDrives[$i])
$Index = _GUICtrlListView_AddItem($T6_List1, StringUpper($aDrives[$i]) & "\", $iLWindex)
_GUICtrlListView_AddSubItem($T6_List1, $Index, Round((DriveSpaceTotal($aDrives[$i]) - DriveSpaceFree($aDrives[$i])) / 1024, 1) & " GB/" & Round(DriveSpaceTotal($aDrives[$i]) / 1024, 1) & " GB", 1, 1)
Switch $iLWindex
Case 4
$iLTyp = "Festplatte"
Case 5
$iLTyp = "CDROM"
Case 6
$iLTyp = "RAMDisk"
Case 3
$iLTyp = "Stick"
Case Else
$ilTyp = $iLWindex
EndSwitch
_GUICtrlListView_AddSubItem($T6_List1, $Index, $iLTyp, 2, 1)
Next
Case 1
GUICtrlSetData($T6_Label1, "Pfad: " & $acPfad)
$Index = _GUICtrlListView_AddItem($T6_List1, "..", 0)
_GUICtrlListView_AddSubItem($T6_List1, $Index, "Dateiordner", 2, 1)
$aFolder = _FileListToArray($acPfad, "*", 2);Folder
If @error Then
Else
For $i = 1 To $aFolder[0]
$Index = _GUICtrlListView_AddItem($T6_List1, $aFolder[$i] & "\", 0)
_GUICtrlListView_AddSubItem($T6_List1, $Index, "Dateiordner", 2, 1)
Next
EndIf
$aFile = _FileListToArray($acPfad, "*", 1);Files
If @error Then
Else
For $i = 1 To $aFile[0]
$Index = _GUICtrlListView_AddItem($T6_List1, $aFile[$i], 1)
_GUICtrlListView_AddSubItem($T6_List1, $Index, "Datei", 2, 1)
Next
EndIf
EndSwitch
EndFunc ;==>_FileExplorer
Func _LeftDblClick($Info)
_FileExplorer2()
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
$hWndListView = $T6_List1
If Not IsHWnd($T6_List1) Then $hWndListView = GUICtrlGetHandle($T6_List1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
;~ _ColumnClick($aInfo)
Case $LVN_DELETEITEM ; An item is about to be deleted
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
;~ _ItemDeleted($aInfo)
Case $LVN_HOTTRACK ; Sent by a list-view control when the user moves the mouse over an item
Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $aInfo[11] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "Param")]
Return 0 ; allow the list view to perform its normal track select processing.
;Return 1 ; the item will not be selected.
;~ _HottTrackItem($aInfo)
Case $LVN_KEYDOWN ; A key has been pressed
Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
Local $aInfo[5] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "VKey"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _KeyDown($aInfo)
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _LeftClick($aInfo)
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
_LeftDblClick($aInfo)
Case $NM_KILLFOCUS ; The control has lost the input focus
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _LostFocus($aInfo)
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
; Return 1 ; not to allow the default processing
Return 0 ; allow the default processing
;~ _RightClick($aInfo)
Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
Local $aInfo[12] = [$hWndFrom, _
$iIDFrom, _
$iCode, _
DllStructGetData($tInfo, "Index"), _
DllStructGetData($tInfo, "SubItem"), _
DllStructGetData($tInfo, "NewState"), _
DllStructGetData($tInfo, "OldState"), _
DllStructGetData($tInfo, "Changed"), _
DllStructGetData($tInfo, "ActionX"), _
DllStructGetData($tInfo, "ActionY"), _
DllStructGetData($tInfo, "lParam"), _
DllStructGetData($tInfo, "KeyFlags")]
;~ _RightDblClick($aInfo)
Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _InputFocusReturn($aInfo)
Case $NM_SETFOCUS ; The control has received the input focus
Local $aInfo[3] = [$hWndFrom, _
$iIDFrom, _
$iCode]
;~ _SetFocus($aInfo)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
das funktioniert auch ziemlich gut...Dann wollte ich es in mein Projekt integrieren...dazu hab ich die ListView in einem Tab gemacht...
so jetz fangen die Probleme an:
wenn ich oben wo die Controls in meinem Tab erstellt werden das hier reinmache:
Global $T6_List1 = _GUICtrlListView_Create($Form1, "", 490, 34, 306, 306)
[/autoit]ist die ListView in jedem Tab sichtbar, aber es lassen sie alle Items löschen(wenn man einen anderen Ordner macht werden die ja vorher alle wieder gelöscht)
wenn ich jetz allerdings
Global $T6_List1 = GUICtrlCreateListView("", 490, 34, 306, 306)
[/autoit]oben reinmache lassen sich die Items nicht mehr löschen aber die ListView ist auch nur in dem jeweiligen Tab verfügbar...
jetzt suche ich verzweifelt nach einer Lösung, für dieses markabere Problem...Ich hoffe ihr könnt mir helfen
/Edit oh paar Darstellungsprobleme im ersten Spoiler naja egal..das ist auch nicht so wichtig fürs problem