Hey,
mal wieder ein Problem zu Listview, hier das Skript:
Spoiler anzeigen
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
Global Const $tagLVKEYDOWN = $tagNMHDR & "; USHORT wVKey; UINT flags;"
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
$ListView1 = GUICtrlCreateListView("Hallo|1", 56, 40, 433, 225,"",BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
$ListView2 = GUICtrlCreateListView("Hallo|2", 56, 40, 433, 225,$LVS_NOSCROLL,BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
$hListView1 = GUICtrlGetHandle($ListView1)
GUICtrlSetState(-1,$GUI_HIDE)
$Button1 = GUICtrlCreateButton("Button1", 64, 288, 129, 49, 0)
$Button2 = GUICtrlCreateButton("Button2", 264, 288, 185, 49, 0)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
for $i = 0 to 20
GUICtrlCreateListViewItem("test|" & $i,$ListView1)
next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button1
GUICtrlSetState($ListView1, $GUI_HIDE)
GUICtrlSetState($ListView2, $GUI_Show)
GUICtrlCreateListViewItem("test|test",$ListView1)
case $Button2
GUICtrlSetState($ListView2, $GUI_HIDE)
GUICtrlSetState($ListView1, $GUI_Show)
GUICtrlCreateListViewItem("test|test",$ListView2)
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR, $tInfo, $wVKey
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hListView1
Switch $iCode
Case $LVN_KEYDOWN
$tNMHDR = DllStructCreate($tagLVKEYDOWN, $ilParam)
$wVKey= DllStructGetData($tNMHDR, "wVKey")
Switch $wVKey
case 40
if _GUICtrlListView_GetSelectionMark($hListView1)+1 = _GUICtrlListView_GetItemCount($hListView1) Then
_GUICtrlListView_SetSelectionMark($hListView1,0)
_GUICtrlListView_SetItemFocused($hListView1,0)
endif
case 38
if _GUICtrlListView_GetSelectedIndices($hListView1) = 0 Then
_GUICtrlListView_SetItemSelected($hListView1, _GUICtrlListView_GetItemCount($hListView1)-1)
_GUICtrlListView_SetItemFocused($hListView1,_GUICtrlListView_GetItemCount($hListView1)-1)
endif
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>_SHLV_WM_NOTIFY
Sinn des Skripts soll sein, dass man die Markierung auf ein KeyUP/Down Event setzen kann.
Und zwar immer wenn das erste oder das letzte Item markiert ist.
Funktioniert auch fast, allerdings springt die Markierung komischerweise immer ein Item zu weit?
Also anstatt z.B. Item 1 (Index 0) zu markieren wird Item 2 (Index 1) markiert.
Probierts am besten mal selbst aus, dann sollte es klar werden.
Gruß nuts