Hi
hier möchte ich euch meine funktion vorstellen
Beispiel:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>
#include <Listview Window.au3>
$Form1 = GUICreate("Form1", 600, 350)
GUIRegisterMsg($WM_NOTIFY, "_ListView_Notify")
GUIRegisterMsg($WM_SIZE, "_ListView_Notify")
$ListView = GUICtrlCreateListView("Text|Rating", 0, 0, 600, 350 )
$hWndListview = GUICtrlGetHandle($ListView)
GUISetState(@SW_SHOW)
For $i = 0 To 40
GUICtrlCreateListViewItem('Text', $ListView)
_ListView_CreateRating($hWndListview, $i, 1, @ScriptDir & "\Star_Full.gif", @ScriptDir & "\Star_Half.gif", 4.5)
Next
Do
$msg = GUIGetMsg()
Until $msg = -3
und hier die funktion:
Spoiler anzeigen
Global $Listview_Window[1][4] = [['Hwnd', 'hwndFrom', 'Index', 'SubIndex']]
[/autoit] [autoit][/autoit] [autoit]Func _ListView_Notify($hWnd, $Msg, $wParam, $lParam)
If $Msg = $WM_SIZE Then
_WinAPI_InvalidateRect($hWnd)
Return $GUI_RUNDEFMSG
EndIf
Local $tNMHEADER, $hWndFrom, $iCode, $i
[/autoit] [autoit][/autoit] [autoit]$tNMHEADER = DllStructCreate($tagNMHEADER, $lParam)
$hWndFrom = DllStructGetData($tNMHEADER, "hwndFrom")
$iCode = DllStructGetData($tNMHEADER, "Code")
Switch $iCode
Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW, $LVN_ENDSCROLL
If $iCode <> $LVN_ENDSCROLL Then $hWndFrom = _WinAPI_GetParent($hWndFrom)
For $i = 1 To UBound($Listview_Window) -1
If $Listview_Window[$i][1] = $hWndFrom Then
_ListView_MoveWindow($hWndFrom, $Listview_Window[$i][0], $Listview_Window[$i][2], $Listview_Window[$i][3])
EndIf
Next
_WinAPI_InvalidateRect($hWndFrom)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _ListView_InsertWindow($hWnd, $Index, $SubItemIndex = 0)
If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
Local $Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
Local $Rect
If BitAND($Style, $WS_CLIPCHILDREN) <> $WS_CLIPCHILDREN Then
_WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($Style, $WS_CLIPCHILDREN))
EndIf
If $SubItemIndex = 0 Then
$Rect = _GUICtrlListView_GetItemRect($hWnd, $Index, 2)
Else
$Rect = _GUICtrlListView_GetSubItemRect($hWnd, $Index, $SubItemIndex)
EndIf
ReDim $Listview_Window[UBound($Listview_Window) +1][UBound($Listview_Window, 2)]
[/autoit] [autoit][/autoit] [autoit]$Listview_Window[UBound($Listview_Window) -1][0] = GUICreate('', $Rect[2]- $Rect[0], $Rect[3] - $Rect[1], $Rect[0], $Rect[1], $WS_CHILD, -1, $Hwnd)
$Listview_Window[UBound($Listview_Window) -1][1] = $hWnd
$Listview_Window[UBound($Listview_Window) -1][2] = $Index
$Listview_Window[UBound($Listview_Window) -1][3] = $SubItemIndex
GUISetState(@SW_SHOW, $Listview_Window[UBound($Listview_Window) -1][0])
Return $Listview_Window[UBound($Listview_Window) -1][0]
EndFunc
Func _ListView_MoveWindow($hWndListView, $hWndWindow, $Index, $SubItemIndex)
Local $Rect
If $SubItemIndex = 0 Then
$Rect = _GUICtrlListView_GetItemRect($hWndListView, $Index, 2)
Else
$Rect = _GUICtrlListView_GetSubItemRect($hWndListView, $Index, $SubItemIndex)
EndIf
If $Rect[1] < 10 Then
_WinAPI_ShowWindow($hWndWindow, 0)
ElseIf $Rect[1] >= 10 Then
_WinAPI_ShowWindow($hWndWindow, 5)
EndIf
_WinAPI_MoveWindow($hWndWindow, $Rect[0], $Rect[1], $Rect[2] - $Rect[0], $Rect[3] - $Rect[1], True)
EndFunc
Func _ListView_CreateRating($hWndListView, $Index, $SubItemIndex, $pImgFull, $pImgHalf, $Rating)
Local $CurrentStep, $Half
$Window = _ListView_InsertWindow($hWndListView, $Index, $SubItemIndex)
GUISetBkColor(0xFFFFFF, $Window)
$WindowSize = WinGetClientSize($Window)
$Step = Round($WindowSize[0] / Ceiling($Rating))
$CurrentStep = 0
$Half = Mod($Rating, Int($Rating))
For $i = 1 To Int($Rating)
GUICtrlCreatePic($pImgFull, $CurrentStep, 3, $Step, $WindowSize[1]-6)
$CurrentStep += $Step
Next
If $Half <> 0 Or $Half <> '' Then
GUICtrlCreatePic($pImgHalf, $CurrentStep, 3, $Step, $WindowSize[1]-6)
EndIf
EndFunc
Die funktion "_ListView_CreateRating" soll euch zeigen was man damit alles anstellen kann.
mit dieser funktion lassen sich so ziemlich alles in einer listview erstellen...
würde mich über feedback freuen und verbesserung vorschläge