Hi zusammen,
ich stecke aktuell leider bei einer Standard- Windowsfunktion fest leider fehlt die gewünschte Funktion in AutoIT. Ich würde gerne den Filtertext einer Listview auslesen und weiterverarbeiten. Leider klappt das auslesen ganz und gar nicht. Vielleicht mag mal jemand drüber schauen, der sich damit auskennt?
Viele Grüße
KriZza
AutoIt
#include <Constants.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <WinAPI.au3>
$gui = GUICreate("listview filter", 400, 250, -1, -1)
$listview = GUICtrlCreateListView("col0|col1|col2", 10, 10, 380, 230)
GUICtrlSendMsg(-1, 0x101E, 0, 125)
GUICtrlSendMsg(-1, 0x101E, 1, 125)
GUICtrlSendMsg(-1, 0x101E, 2, 125)
GUICtrlCreateListViewItem("blue|green|blue", $listview)
GUICtrlCreateListViewItem("red|blue|green", $listview)
GUICtrlCreateListViewItem("green|red|red", $listview)
GUICtrlCreateListViewItem("blue|green|blue", $listview)
GUICtrlCreateListViewItem("red|blue|green", $listview)
GUICtrlCreateListViewItem("green|red|red", $listview)
GUICtrlCreateListViewItem("blue|green|blue", $listview)
GUICtrlCreateListViewItem("red|blue|green", $listview)
GUICtrlCreateListViewItem("green|red|red", $listview)
GUICtrlCreateListViewItem("blue|green|blue", $listview)
GUICtrlCreateListViewItem("red|blue|green", $listview)
GUICtrlCreateListViewItem("green|red|red", $listview)
GUISetState()
;Use of lock/unlock and begin/end update is just to cause repainting so the filterbar is fully visible
GUISetState(@SW_LOCK, $gui)
_GUICtrlListView_BeginUpdate($listview)
;Add the filter bar to the header control
$header = _GUICtrlListView_GetHeader($listview)
$styles = _WinAPI_GetWindowLong($header, $GWL_STYLE)
_WinAPI_SetWindowLong($header, $GWL_STYLE, BitOR($styles, $HDS_FILTERBAR))
;Use of lock/unlock and begin/end update is just to cause repainting so the filterbar is fully visible
_GUICtrlListView_EndUpdate($listview)
GUISetState(@SW_UNLOCK, $gui)
_GUICtrlHeader_EditFilter($header, 0)
Send("Filter 1")
;Register WM_NOTIFY to handle $HDN_FILTERBTNCLICK messages
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Sleep(1000)
MsgBox(0,"",_GUICtrlHeader_GetFilterText($header, 0))
;Loop GUI until exit
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode
Local $tNMHDR, $tNMHEADER, $tNMHDFILTERBTNCLICK, $tHDTEXTFILTER, $tNMHDDISPINFO
Local $iHeaderItem, $tItem
Local $HDFT_ISSTRING = 0x0
Local $HDFT_ISNUMBER = 0x1
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $header
Switch $iCode
Case $HDN_FILTERBTNCLICK ; Notifies the header control's parent window when the filter button is clicked or in response to an $HDM_SETITEM message
$tNMHDFILTERBTNCLICK = DllStructCreate($tagNMHDFILTERBTNCLICK, $ilParam)
$tHDTEXTFILTER = DllStructCreate($tagHDTEXTFILTER, $ilParam)
$column = DllStructGetData($tNMHDFILTERBTNCLICK, "Item")
$text = DllStructGetData($tHDTEXTFILTER, "Text")
MsgBox(0, "Msg", "Filter button click for column " & $column & @CRLF & _
"Text: " & $text)
;Return True ; An $HDN_FILTERCHANGE notification will be sent to the header control's parent window
; This notification gives the parent window an opportunity to synchronize its user interface elements
Return False ; If you do not want the notification sent
Case $HDN_FILTERCHANGE ; Notifies the header control's parent window that the attributes of a header control filter are being changed or edited
;$tNMHEADER = DllStructCreate($tagNMHEADER, $ilParam)
; no return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _GUICtrlHeader_GetFilterText($hWnd, $iIndex)
Local $bUnicode = _GUICtrlHeader_GetUnicodeFormat($hWnd)
Local $tBuffer
If $bUnicode Then
$tBuffer = DllStructCreate("wchar Text[4096]")
Else
$tBuffer = DllStructCreate("char Text[4096]")
EndIf
Local $tItem = DllStructCreate($tagHDTEXTFILTER)
DllStructSetData($tItem, "TextMax", 4096)
If _WinAPI_InProcess($hWnd, $__g_hHDRLastWnd) Then
DllStructSetData($tItem, "Text", DllStructGetPtr($tBuffer))
_SendMessage($hWnd, $HDM_GETITEMW, $iIndex, $tItem, 0, "wparam", "struct*")
Else
Local $iItem = DllStructGetSize($tItem)
Local $tMemMap
Local $pMemory = _MemInit($hWnd, $iItem + DllStructGetSize($tBuffer), $tMemMap)
Local $pText = $pMemory + $iItem
DllStructSetData($tItem, "Text", $pText)
_MemWrite($tMemMap, $tItem, $pMemory, $iItem)
If $bUnicode Then
_SendMessage($hWnd, $HDM_GETITEMW, $iIndex, $pMemory, 0, "wparam", "ptr")
Else
_SendMessage($hWnd, $HDM_GETITEMA, $iIndex, $pMemory, 0, "wparam", "ptr")
EndIf
_MemRead($tMemMap, $pText, $tBuffer, DllStructGetSize($tBuffer))
_MemFree($tMemMap)
EndIf
Return DllStructGetData($tBuffer, "Text")
EndFunc ;==>_GUICtrlHeader_GetItemText
Alles anzeigen