Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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, "My Title", "Text", Default, _
- @DesktopWidth / 2, @DesktopHeight / 2 - 120, 2 + 16, 0xFFFFFF, 0x985428, $hIcon)
- _WinAPI_DestroyIcon($hIcon)
- Do
- Until BitAND(WinGetState($hToolTip1), 2) <> 2 ; exit if Tooltip not visible (closed by balloon tip button)
- _GUIToolTip_Destroy($hToolTip1)
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement