Jump to content

ToolTip() Vs. _GUIToolTip


Recommended Posts

The problem is simple, the answer I have no idea about.

I really like the tooltip function. It's very simple to use. I'm using it very effectively too. What's nice about it is that I can arbitrarily place it wherever I'd like.

_GUIToolTip is not very well documented as it is missing any examples. From what I've gathered though _GUIToolTip can only be displayed at a control. However, GUIToolTip can be extensively customized with different colors and such.

My problem: I need to ability to display a tooltip anywhere like you can with ToolTip() but I also need to customize that tooltip so that the colors are not default. What is the best avenue for achieving my goals here?

Thanks is advance.

Link to comment
Share on other sites

Did you try _GuiToolTip_SetToolInfo()?

:mellow:

Ha, uh, well I gladly would have tried that though I'm quite confounded by the entire _GUIToolTip set of functions. After looking at _GuiToolTip_SetToolInfo() I only further confused myself. I'm not sure of how to properly use any of these functions of GUIToolTip I only barely grasp the concept of them.

In the left picture shown below I have accomplished the effect with ToolTip(). I guess my big question is how can I achieve the effect shown in the right picture

Posted Image

Link to comment
Share on other sites

Hmm... my first attempt at a demo was a complete failure. :mellow:

Looking for more info now.

:P

Edit: Here is a working example by Rover, though it's not quite what's wanted since it floats independent tooltips not associated with any window/control.

Rover's example of multiple tooltips:

#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, 0xFFFFFF, 0x985428, $hIcon)

Global $hToolTip2 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 2", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2, 2 + 16, 0xFF0000, 0xFFFFFF, $hIcon)

Global $hToolTip3 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 3", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2 + 75, 2 + 16)

Global $hToolTip4 = _GUIToolTip_CreateToolTip(0, "", "ToolTip 4", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2 + 130, 32 + 16)

_WinAPI_DestroyIcon($hIcon)

;Sleep(2000)
;Hide
;_GUIToolTip_TrackActivate($hToolTip1, False, 0, 0)
;Sleep(2000)
;Show
;_GUIToolTip_TrackActivate($hToolTip1, True, 0, 0)

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

Also found an alternative UDF by rasim: ToolTip_UDF

:party:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hmm... my first attempt at a demo was a complete failure. :mellow:

Looking for more info now.

:P

Edit: Here is a working example by Rover, though it's not quite what's wanted since it floats independent tooltips not associated with any window/control.

Rover's example of multiple tooltips:

#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, 0xFFFFFF, 0x985428, $hIcon)

Global $hToolTip2 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 2", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2, 2 + 16, 0xFF0000, 0xFFFFFF, $hIcon)

Global $hToolTip3 = _GUIToolTip_CreateToolTip(0, "UDF ToolTip", "ToolTip 3", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2 + 75, 2 + 16)

Global $hToolTip4 = _GUIToolTip_CreateToolTip(0, "", "ToolTip 4", 0, _
        @DesktopWidth / 2, @DesktopHeight / 2 + 130, 32 + 16)

_WinAPI_DestroyIcon($hIcon)

;Sleep(2000)
;Hide
;_GUIToolTip_TrackActivate($hToolTip1, False, 0, 0)
;Sleep(2000)
;Show
;_GUIToolTip_TrackActivate($hToolTip1, True, 0, 0)

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

Also found an alternative UDF by rasim: ToolTip_UDF

:party:

Woowww, Thanks alot. This is pretty much exactly what I need =D. one thing though, I don't know if this is merely an bug on my end or what, but the text and background color parameters in his function won't change the text or background color. The values he has inserted do not work and neither do the ones I tried. Any ideas? Is that value supposed to be a hexadecimal?
Link to comment
Share on other sites

I don't know if this is merely an bug on my end or what, but the text and background color parameters in his function won't change the text or background color. The values he has inserted do not work and neither do the ones I tried. Any ideas? Is that value supposed to be a hexadecimal?

It is a 24bit RGB value, but it should be converted to Microsoft COLORREF, or BGR when actually sent in the TTM_SETTIPBKCOLOR message. It doesn't look like the old _GUIToolTip_SetTipBkColor() function makes that conversion, but it is an old PaulIA function that might date from the times when AutoIt functions in general were BGR by default. The alternate UDF by rasim does a conversion from RGB to BGR in its _ToolTip_SetBkColor().

Neither the GuiToolTip.au3, nor rasim's UDF produce different background colors for me. That leads me to believe you have to turn off a default theme or style selection before it will take.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It is a 24bit RGB value, but it should be converted to Microsoft COLORREF, or BGR when actually sent in the TTM_SETTIPBKCOLOR message. It doesn't look like the old _GUIToolTip_SetTipBkColor() function makes that conversion, but it is an old PaulIA function that might date from the times when AutoIt functions in general were BGR by default. The alternate UDF by rasim does a conversion from RGB to BGR in its _ToolTip_SetBkColor().

Neither the GuiToolTip.au3, nor rasim's UDF produce different background colors for me. That leads me to believe you have to turn off a default theme or style selection before it will take.

:mellow:

Okay, so I disabled the vista theme and chose windows classic. I tried the balloon...it worked. Which is good...but I'll need it to work with any theme turned on. I hope I'm not being irritating. But were you suggesting that there is a way to disable theme styling on the balloon itself? If that were the case this would be perfect.

EDIT: Ehh, nevermind. No matter what the background was black. Also setting the text color was odd too. I changed it to several values, some in hexadecimal and some in BGR they all came out either burnt orange or dark gray. And oddly enough some of the color values messed up the positioning on the balloon.

Edited by JohnnyThrash
Link to comment
Share on other sites

Okay, so I disabled the vista theme and chose windows classic. I tried the balloon...it worked. Which is good...but I'll need it to work with any theme turned on. I hope I'm not being irritating. But were you suggesting that there is a way to disable theme styling on the balloon itself? If that were the case this would be perfect.

The post ResNullius linked to shows how to disable the theme for a particular handle, which could be either a window or a control, I believe.

EDIT: Ehh, nevermind. No matter what the background was black. Also setting the text color was odd too. I changed it to several values, some in hexadecimal and some in BGR they all came out either burnt orange or dark gray. And oddly enough some of the color values messed up the positioning on the balloon.

I'd like to see examples of the values you tried.

There is no such thing as BGR, RGB, Binary, Decimal, or Hexadecimal in the actual value used. It's a 32-bit integer, regardless. Those are just different ways of presenting the data for human viewing. BGR and RGB do put the colors in different bit locations, but Hexadecimal is just a convenient format for humans to read either one.

This modification of Rover's example works for me. It uses a modification of ResNullius' function to achieve the color changes, and Siao's conversion of the colors from RGB to BGR:

#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

:mellow:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This modification of Rover's example works for me. It uses a modification of ResNullius' function to achieve the color changes, and Siao's conversion of the colors from RGB to BGR...

Nice combo, works on Win7, well done :mellow: Edited by KaFu
Link to comment
Share on other sites

The post ResNullius linked to shows how to disable the theme for a particular handle, which could be either a window or a control, I believe.

I'd like to see examples of the values you tried.

There is no such thing as BGR, RGB, Binary, Decimal, or Hexadecimal in the actual value used. It's a 32-bit integer, regardless. Those are just different ways of presenting the data for human viewing. BGR and RGB do put the colors in different bit locations, but Hexadecimal is just a convenient format for humans to read either one.

This modification of Rover's example works for me. It uses a modification of ResNullius' function to achieve the color changes, and Siao's conversion of the colors from RGB to BGR:

#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

:mellow:

Thanks alot! Between you and the other help I've gotten I've been able to achieve my desired effect!

Also I made a function that might be useful to some people.

It's just to simply convert hexadecimal values to ColorRef Format.

Func _HexToColorRef($Hex)
    $Hex=StringRight($Hex, 6)
    $R=StringLeft($Hex, 2)
    $G=StringMid($Hex, 3, 2)
    $B=StringRight($Hex, 2)
    $Colorref=Number("0x00" & $B & $G & $R)
    Return $Colorref
    
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...