#include <GuiToolTip.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global $iIconID = 43
If @OSVersion == "WIN_VISTA" Then $iIconID = 51
Global $hIcon = _WinAPI_LoadShell32Icon($iIconID)
Global $hToolTip1 = _GUIToolTip_CreateToolTip(0, "Close tooltip to exit", "ToolTip 1", Default, _
@DesktopWidth / 2, @DesktopHeight / 2 - 120, 2 + 16, 0xFF00, 0xFF0000, $hIcon)
_SetTipColors($hToolTip1, 0xFF00, 0xFF0000)
Global $hToolTip2 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 2", 0, _
@DesktopWidth / 2, @DesktopHeight / 2, 2 + 16, 0xFF0000, 0x00FF00, $hIcon)
_SetTipColors($hToolTip2, 0xFF0000, 0x00FF00)
Global $hToolTip3 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 3", 0, _
@DesktopWidth / 2, @DesktopHeight / 2 + 75, 2 + 16, 0, 0xFFFFFF)
_SetTipColors($hToolTip3, 0, 0xFFFFFF)
Global $hToolTip4 = _GUIToolTip_CreateToolTip(0, "", "ToolTip 4", 0, _
@DesktopWidth / 2, @DesktopHeight / 2 + 130, 32 + 16, 0xFFFFFF, 0) ;
_SetTipColors($hToolTip4, 0xFFFFFF, 0)
_WinAPI_DestroyIcon($hIcon)
Do
Sleep(10)
Local $aPos = MouseGetPos()
_GUIToolTip_TrackPosition($hToolTip4, $aPos[0] + 10, $aPos[1] + 20)
_GUIToolTip_UpdateTipText($hToolTip4, 0, 0, "X: " & $aPos[0] & " Y: " & $aPos[1])
Until BitAND(WinGetState($hToolTip1), 2) <> 2 ; exit if Tooltip not visible (closed by balloon tip button)
_GUIToolTip_Destroy($hToolTip1)
_GUIToolTip_Destroy($hToolTip2)
_GUIToolTip_Destroy($hToolTip3)
_GUIToolTip_Destroy($hToolTip4)
Func _GUIToolTip_CreateToolTip($hWnd, $sTitle, $sText, $iStyle = Default, $iX = -1, _
$iY = -1, $iFlags = 0, $iColTxt = Default, $iColBk = Default, $iIcon = 0)
;Author: rover and et al.
;$iIcon [optional] Pre-defined icon to show next to the title: Requires a title.
;0 = No icon, 1 = Info icon, 2 = Warning icon, 3 = Error Icon
; From _GUIToolTip_SetTitle() remarks
; As of Windows XP SP2 and later, $iIcon can contain an HICON value.
; Any value greater than 3 is assumed to be an HICON.
Local Const $CW_USEDEFAULT = 0x80000000
If Not IsHWnd($hWnd) Or IsKeyword($hWnd) Then $hWnd = 0
If IsKeyword($iX) Or $iX < 0 Or Not IsNumber($iX) Then $iX = 0
If IsKeyword($iY) Or $iY < 0 Or Not IsNumber($iY) Then $iY = 0
If IsKeyword($iFlags) Or $iFlags <= 0 Or Not IsNumber($iFlags) Then $iFlags = 32 + 8 + 1
If IsKeyword($iStyle) Then $iStyle = BitOR($TTS_BALLOON, $TTS_CLOSE)
Local $hTip = _WinAPI_CreateWindowEx($WS_EX_TOPMOST, "tooltips_class32", "", _
BitOR($iStyle, $TTS_ALWAYSTIP, $TTS_NOPREFIX), _
$CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $hWnd)
_GUIToolTip_AddTool($hTip, $hWnd, $sText, $hWnd, 0, 0, 0, 0, $iFlags, 0)
If Number($iIcon) > 3 And @OSVersion = "WIN_XP" And Number(StringRight(@OSServicePack, 1)) < 2 Then $iIcon = 0
If Not IsNumber($iIcon) Or $iIcon < 0 Then $iIcon = 0
_GUIToolTip_SetTitle($hTip, $sTitle, $iIcon)
If IsInt($iColTxt) Then _GUIToolTip_SetTipTextColor($hTip, $iColTxt)
If IsInt($iColBk) Then _GUIToolTip_SetTipBkColor($hTip, $iColBk)
If $hWnd = 0 Or $hWnd = -1 Or IsKeyword($hWnd) Then
_GUIToolTip_TrackPosition($hTip, $iX, $iY)
_GUIToolTip_TrackActivate($hTip, True, $hWnd, $hWnd)
Return $hTip
EndIf
Return $hTip
EndFunc ;==>_GUIToolTip_CreateToolTip
Func _SetTipColors($hWnd, $iBkColor, $iTxtColor)
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hWnd, "wstr", "", "wstr", "")
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $TTM_SETTIPBKCOLOR, "int", _RGB2BGR($iBkColor), "int", 0)
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "int", $TTM_SETTIPTEXTCOLOR, "int", _RGB2BGR($iTxtColor), "int", 0)
EndFunc ;==>_SetTipColors
; #FUNCTION# =============================================================
; Name............: RGB2BGR
; Description.....: Convert a RGB color mode to a BGR color mode
; Syntax..........: RGB2BGR($sColor)
; Parameter(s)....: $sColor - The color in HEX value
; Return value(s).: Converted color in HEX value
; Requirement(s)..:
; Note(s).........:
; Author(s).......: Siao
; ========================================================================
Func _RGB2BGR($iColor)
Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc ;==>_RGB2BGR