Advertisement
Guest User

Untitled

a guest
Apr 6th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.39 KB | None | 0 0
  1. #include <GuiToolTip.au3>
  2. #include <WinAPI.au3>
  3. #include <WindowsConstants.au3>
  4. Opt('MustDeclareVars', 1)
  5. Global $iIconID = 43
  6. If @OSVersion == "WIN_VISTA" Then $iIconID = 51
  7. Global $hIcon = _WinAPI_LoadShell32Icon($iIconID)
  8. Global $hToolTip1 = _GUIToolTip_CreateToolTip(0, "My Title", "Text", Default, _
  9.         @DesktopWidth / 2, @DesktopHeight / 2 - 120, 2 + 16, 0xFFFFFF, 0x985428, $hIcon)
  10. _WinAPI_DestroyIcon($hIcon)
  11. Do
  12. Until BitAND(WinGetState($hToolTip1), 2) <> 2 ; exit if Tooltip not visible (closed by balloon tip button)
  13. _GUIToolTip_Destroy($hToolTip1)
  14. Func _GUIToolTip_CreateToolTip($hwnd, $sTitle, $sText, $iStyle = Default, $iX = -1, _
  15.         $iY = -1, $iFlags = 0, $iColTxt = Default, $iColBk = Default, $iIcon = 0)
  16.     ;Author: rover and et al.
  17.     ;$iIcon [optional] Pre-defined icon to show next to the title: Requires a title.
  18.     ;0 = No icon, 1 = Info icon, 2 = Warning icon, 3 = Error Icon
  19.     ; From _GUIToolTip_SetTitle() remarks
  20.     ; As of Windows XP SP2 and later, $iIcon can contain an HICON value.
  21.     ; Any value greater than 3 is assumed to be an HICON.
  22.     Local Const $CW_USEDEFAULT = 0x80000000
  23.     If Not IsHWnd($hwnd) Or IsKeyword($hwnd) Then $hwnd = 0
  24.     If IsKeyword($iX) Or $iX < 0 Or Not IsNumber($iX) Then $iX = 0
  25.     If IsKeyword($iY) Or $iY < 0 Or Not IsNumber($iY) Then $iY = 0
  26.     If IsKeyword($iFlags) Or $iFlags <= 0 Or Not IsNumber($iFlags) Then $iFlags = 32 + 8 + 1
  27.     If IsKeyword($iStyle) Then $iStyle = BitOR($TTS_BALLOON, $TTS_CLOSE)
  28.     Local $hTip = _WinAPI_CreateWindowEx($WS_EX_TOPMOST, "tooltips_class32", "", _
  29.     BitOR($iStyle, $TTS_ALWAYSTIP, $TTS_NOPREFIX), _
  30.     $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $hWnd)
  31.  
  32.     _GUIToolTip_AddTool($hTip, $hwnd, $sText, $hwnd, 0, 0, 0, 0, $iFlags, 0)
  33.     If Number($iIcon) > 3 And @OSVersion = "WIN_XP" And Number(StringRight(@OSServicePack, 1)) < 2 Then $iIcon = 0
  34.     If Not IsNumber($iIcon) Or $iIcon < 0 Then $iIcon = 0
  35.     _GUIToolTip_SetTitle($hTip, $sTitle, $iIcon)
  36.     If IsInt($iColTxt) Then _GUIToolTip_SetTipTextColor($hTip, $iColTxt)
  37.     If IsInt($iColBk) Then _GUIToolTip_SetTipBkColor($hTip, $iColBk)
  38.  
  39.     If $hwnd = 0 Or $hwnd = -1 Or IsKeyword($hwnd) Then
  40.         _GUIToolTip_TrackPosition($hTip, $iX, $iY)
  41.         _GUIToolTip_TrackActivate($hTip, True, $hwnd, $hwnd)
  42.         Return $hTip
  43.     EndIf
  44.  
  45.     Return $hTip
  46. EndFunc   ;==>_GUIToolTip_CreateToolTip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement