- Offizieller Beitrag
Hi, Oscar.
Irgendwie will das Automatische setzen der Spaltenbreiten der Listviews nicht richtig.
Wenn man z.B. den Header des nicht aktiven Listviews verändert funzt das resizen erst wenn man die
Maustaste wieder losläßt. Das Resizen der Spalten ist auch ziehmlich ruckelich. Ich hab da mal einen
Lösungsvorschlag für dich. Dabei funzt das Resizen auch wenn man den Header des
nicht aktiven Listviews ändert. Ist auch ein bischen performanter. Schau es dir mal an,
wenn es dir zusagt kannst du es ja in dein Script integrieren.
Spoiler anzeigen
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $tNMHDR, $hWndFrom, $tInfo, $iItem, $sText, $sPath, $sExt
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
Switch $hWndFrom
case _GUICtrlListView_GetHeader($ahLV[0])
Switch DllStructGetData($tNMHDR, 'Code')
Case -321
_CheckLVColWidth(0)
EndSwitch
case _GUICtrlListView_GetHeader($ahLV[1])
Switch DllStructGetData($tNMHDR, 'Code')
Case -321
_CheckLVColWidth(1)
EndSwitch
Case GUICtrlGetHandle($ahLV[0])
Switch DllStructGetData($tNMHDR, 'Code')
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iItem = DllStructGetData($tInfo, 'Index')
$sText = _GUICtrlListView_GetItemText($ahLV[0], $iItem, 0)
Switch $sText
Case ''
; nothing
Case '..'
$sPath = StringRegExpReplace(GUICtrlRead($ahPath[0]), '(.+\\).+\\', '$1')
GUICtrlSetData($ahPath[0], $sPath)
_CreateListViewItems($ahLV[0], $sPath)
Case Else
$sExt = _GUICtrlListView_GetItemText($ahLV[0], $iItem, 1)
If $sExt <> '' Then $sExt = '.' & $sExt
$sPath = GUICtrlRead($ahPath[0]) & $sText
Switch $sExt
Case '.<DIR>'
$sPath &= '\'
GUICtrlSetData($ahPath[0], $sPath)
_CreateListViewItems($ahLV[0], $sPath)
Case Else
ShellExecute($sPath & $sExt)
EndSwitch
EndSwitch
Case $NM_SETFOCUS
$iActiveLV = 0
$sOldSelItems = '|'
GUICtrlSetBkColor($ahPath[0], 0x005599)
GUICtrlSetColor($ahPath[0], 0xFFFF22)
GUICtrlSetBkColor($ahPath[1], 0xEEEEEE)
GUICtrlSetColor($ahPath[1], 0x000000)
EndSwitch
Case GUICtrlGetHandle($ahLV[1])
Switch DllStructGetData($tNMHDR, 'Code')
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iItem = DllStructGetData($tInfo, 'Index')
$sText = _GUICtrlListView_GetItemText($ahLV[1], $iItem, 0)
Switch $sText
Case ''
; nothing
Case '..'
$sPath = StringRegExpReplace(GUICtrlRead($ahPath[1]), '(.+\\).+\\', '$1')
GUICtrlSetData($ahPath[1], $sPath)
_CreateListViewItems($ahLV[1], $sPath)
Case Else
$sExt = _GUICtrlListView_GetItemText($ahLV[1], $iItem, 1)
If $sExt <> '' Then $sExt = '.' & $sExt
$sPath = GUICtrlRead($ahPath[1]) & $sText
Switch $sExt
Case '.<DIR>'
$sPath &= '\'
GUICtrlSetData($ahPath[1], $sPath)
_CreateListViewItems($ahLV[1], $sPath)
Case Else
ShellExecute($sPath & $sExt)
EndSwitch
EndSwitch
Case $NM_SETFOCUS
$iActiveLV = 1
$sOldSelItems = '|'
GUICtrlSetBkColor($ahPath[1], 0x005599)
GUICtrlSetColor($ahPath[1], 0xFFFF22)
GUICtrlSetBkColor($ahPath[0], 0xEEEEEE)
GUICtrlSetColor($ahPath[0], 0x000000)
EndSwitch
EndSwitch
$tNMHDR = ''
$tInfo = ''
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _CheckLVColWidth($iLV)
For $i = 0 To 4
_GUICtrlListView_SetColumnWidth($ahLV[1 - $iLV], $i, _GUICtrlListView_GetColumnWidth($ahLV[$iLV], $i))
Next
EndFunc ;==>_CheckLVColWidth
Edit: Was hällst du davon wenn man die Reihenfolge der ListviewSpalten frei verändern kann?
Ich fände es praktisch wenn man selber bestimmern kann, welche Informationen man an welcher Stelle angezeigt bekommt.