Du wolltest den ToolTip ja auf dem ListItem haben:
Du kannst die Position und Größe des Items mit _GuiCtrlListBox_GetItemRect abfragen.
Ich hab mal ein Beispiel erstellt. Dabei werden auch mehrere ToolTips hintereinander angezeigt, ohne dass die GUI blockiert.
Ich hab als alternative zu den Timern mal AdlibRegister genutzt.
AutoIt
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <ListBoxConstants.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $mGuiData[]
Local $sMESSAGE = "||"
$mGuiData.hGui = GUICreate("My GUI list") ; will create a dialog box that when displayed is centered
$mGuiData.idList = GUICtrlCreateList("", 64, 32, 121, 97, BitOR($WS_VSCROLL, $LBS_USETABSTOPS))
GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling
GUICtrlSetData(-1, "||")
GUICtrlSetData(-1, "1. Item")
$mGuiData.idButtonClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25)
$mGuiData.idButtonToolTip = GUICtrlCreateButton("show tooltips", 64, 200, 175, 25)
GUISetState(@SW_SHOW)
_showTooltips($mGuiData)
; Loop until the user exits.
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $mGuiData.idButtonClose
MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2)
Exit
Case $mGuiData.idButtonToolTip
_showTooltips($mGuiData)
EndSwitch
WEnd
EndFunc ;==>Example
Func _showTooltips(ByRef $mGuiData, $bContinue = False)
Local Static $iCurrent = 0
Local Static $mData
If $mGuiData<>Default Then $mData = $mGuiData
If Not $bContinue Then $iCurrent = 0
Switch $iCurrent
Case 0 ; first toolbar
Local $arPos = _GuiCtrlListBox_GetGlobalItemPos($mData.idList, 1)
_showToolTip($arPos[0] + ($arPos[2]*0.2), $arPos[1] + ($arPos[3]*0.9), "Listview item", 5)
Case 1 ; second toolbar
Local $arPos = _windowGetPos(GUICtrlGetHandle($mData.idButtonClose))
_showToolTip($arPos[0] + ($arPos[2]/2), $arPos[1] + ($arPos[3]/2), "Close button", 3)
Case 2 ; ...
Case Else
; Done
EndSwitch
$iCurrent += 1
EndFunc
Func _windowGetPos($hGui)
Local $tagRect = _WinAPI_GetWindowRect($hGui)
Local $arPos = [DllStructGetData($tagRect, 1), DllStructGetData($tagRect, 2), DllStructGetData($tagRect, 3) - DllStructGetData($tagRect, 1), DllStructGetData($tagRect, 4) - DllStructGetData($tagRect, 2)]
Return $arPos
EndFunc
Func _GuiCtrlListBox_GetGlobalItemPos($idList, $iIndex)
Local $arCtrlPos = _windowGetPos(GUICtrlGetHandle($idList))
Local $arItemPos = _GUICtrlListBox_GetItemRect($idList, 1)
Local $arRes = [$arCtrlPos[0]+$arItemPos[0], $arCtrlPos[1]+$arItemPos[1], $arItemPos[2]-$arItemPos[0], $arItemPos[3]-$arItemPos[1]]
Return $arRes
EndFunc
Func _showToolTip($x, $y, $sMessage, $iTimeS, $sTitle = "INFO", $iIcon = 1, $iOptions = 1)
ToolTip($sMessage, $x, $y, $sTitle, $iIcon, $iOptions)
AdlibRegister("_hideToolTip", $iTimeS*1000)
EndFunc
Func _hideToolTip()
ToolTip("")
AdlibUnRegister("_hideToolTip")
Local $oTmp = Default
_showTooltips($oTmp, True)
EndFunc
Alles anzeigen