D�finit la dur�e pendant laquelle le curseur de la souris doit survoler un �l�ment avant qu'il soit s�lectionn�
#include <GuiListView.au3>
_GUICtrlListView_SetHoverTime ( $hWnd, $iTime )
$hWnd | ID/handle du contr�le |
$iTime | La dur�e nouvelle, en millisecondes, pendant laquelle le curseur de la souris doit survoler un �l�ment avant qu'il soit s�lectionn�. Si cette valeur est (DWORD)-1, alors le temps de survol est d�fini � la dur�e de survol par d�faut. |
Le dur�e de survol ne concerne que les contr�les ListeView qui ont le style �tendu $LVS_EX_TRACKSELECT, $LVS_EX_ONECLICKACTIVATE, ou $LVS_EX_TWOCLICKACTIVATE.
#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiStatusBar.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $g_idListView, $g_hStatus Example() Func Example() Local $hGUI Local $iStylesEX = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT) $hGUI = GUICreate("ListView Set Hover Time", 400, 300) $g_idListView = GUICtrlCreateListView("", 2, 2, 394, 268) _GUICtrlListView_SetHoverTime($g_idListView, 1000) _GUICtrlListView_SetExtendedListViewStyle($g_idListView, $iStylesEX) $g_idListView = GUICtrlGetHandle($g_idListView) $g_hStatus = _GUICtrlStatusBar_Create($hGUI, -1, "") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Ajoute des colonnes _GUICtrlListView_AddColumn($g_idListView, "Column 1", 100) _GUICtrlListView_AddColumn($g_idListView, "Column 2", 100) _GUICtrlListView_AddColumn($g_idListView, "Column 3", 100) _GUICtrlListView_InsertItem($g_idListView, "Row 1: Col 1") _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($g_idListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_InsertItem($g_idListView, "Row 2: Col 1") _GUICtrlListView_AddSubItem($g_idListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_InsertItem($g_idListView, "Row 3: Col 1") ; Obtient la dur�e de survol MsgBox($MB_SYSTEMMODAL, "Information", "Previous Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($g_idListView)) ; D�finit la dur�e de survol _GUICtrlListView_SetHoverTime($g_idListView, 500) MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($g_idListView)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func ListView_HOTTRACK($iSubItem) Local $iHotItem = _GUICtrlListView_GetHotItem($g_idListView) If $iHotItem <> -1 Then _GUICtrlStatusBar_SetText($g_hStatus, @TAB & "Hot Item: " & $iHotItem & " SubItem: " & $iSubItem) EndFunc ;==>ListView_HOTTRACK Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $g_idListView If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; Une colonne a �t� cliqu�e $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ; Aucune valeur retourn�e Case $LVN_HOTTRACK ; Envoy� par un contr�le ListView quand l'utilisateur d�place la souris sur un �l�ment $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) _DebugPrint("$LVN_HOTTRACK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->Param:" & @TAB & DllStructGetData($tInfo, "Param")) ListView_HOTTRACK(DllStructGetData($tInfo, "SubItem")) Return 0 ; allow the list view to perform its normal track select processing. ; Return 1 ; L'�l�ment ne sera pas s�lectionn�. Case $LVN_KEYDOWN ; Une touche a �t� press�e $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) _DebugPrint("$LVN_KEYDOWN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @CRLF & _ "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags")) ; Aucune valeur retourn�e Case $NM_CLICK ; Envoy� par un contr�le ListView quand l'utilisateur clique sur un �l�ment avec le bouton gauche de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retourn�e Case $NM_DBLCLK ; Envoy� par un contr�le ListView quand l'utilisateur double-clique sur un �l�ment avec le bouton gauche de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_DBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retourn�e Case $NM_KILLFOCUS ; Le contr�le a perdu le focus d'entr�e _DebugPrint("$NM_KILLFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retourn�e Case $NM_RCLICK ; Envoy� par un contr�le ListView quand l'utilisateur clique sur un �l�ment avec le bouton droit de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Return 1 ; ne permet pas le traitement par d�faut Return 0 ; permet le traitement par d�faut Case $NM_RDBLCLK ; Envoy� par un contr�le ListView quand l'utilisateur double-clique sur un �l�ment avec le bouton droit de la souris $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) _DebugPrint("$NM_RDBLCLK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode & @CRLF & _ "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _ "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _ "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _ "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _ "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _ "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _ "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _ "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _ "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags")) ; Aucune valeur retourn�e Case $NM_RETURN ; Le contr�le a le focus d'entr�e et l'utilisateur a press� la touche ENTER _DebugPrint("$NM_RETURN" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retourn�e Case $NM_SETFOCUS ; Le contr�le a re�u le focus d'entr�e _DebugPrint("$NM_SETFOCUS" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _ "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _ "-->Code:" & @TAB & $iCode) ; Aucune valeur retourn�e EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @CRLF & _ "+======================================================" & @CRLF & _ "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _ "+======================================================" & @CRLF) EndFunc ;==>_DebugPrint