Jump to content

GUICtrlSetTip()


Realm
 Share

Recommended Posts

I was setting some rather long tooltips with GUICtrlSetTip(), and it tends to timeout before I can finish reading the tip. Is there a way to increase the delay in the timeout?

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

Here's my custom tooltip function, should do the trick ;)...

#include<Timers.au3>

HotKeySet("{ESC}", "_Exit")
Global $__timer_ToolTipEx, $__timer_ToolTipEx_Timeout, $__timer_ToolTipEx_Idle, $__timer_ToolTipEx_Idle_Save

_ToolTipEx("Text....suicidal tooltip example #1...", @DesktopWidth / 2, @DesktopHeight / 2, "_ToolTipEx Title", Default, Default, 2000, 2000)

While 1
    Sleep(1000)
    ConsoleWrite(TimerInit() & @TAB & "Main" & @CRLF)
WEnd

Func _ToolTipEx($sText, $iX = Default, $iY = Default, $sTitle = "", $iIcon = 0, $iOptions = 0, $iTimoutMS = 0, $iTimout_IldeFaderMS = 0, $hWnd = 0)
    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _ToolTipEx
    ; Description....: Custom ToolTip function
    ; Syntax.........: _ToolTipEx($sText, $iX = Default, $iY = Default, $sTitle = "", $iIcon = 0, $iOptions = 0, $iTimoutMS = 0, $iTimout_IldeFaderMS = 0, $hWnd = 0)
    ; Parameters.....:  $sText                  - ToolTip Text
    ;                   $iX                     - x position of ToolTip
    ;                   $iY                     - y position of ToolTip
    ;                   $sTitle                 - Title
    ;                   $iIcon                  - (see ToolTip syntax)
    ;                   $iOptions               - (see ToolTip syntax)
    ;                   $iTimoutMS              - Timeout ToolTip after x ms
    ;                   $iTimout_IldeFaderMS    - Delay ToolTip timeout while computer idle (timeout starts when mouse is moved or key is pressed)
    ;                   $hWnd                   - Control handle to attach ToolTip to, overrides x and y
    ; Return values..: -
    ; Author.........: KaFu
    ; ===============================================================================================================================

    If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)

    If Not IsHWnd($hWnd) Then
        If IsKeyword($iX) Or IsKeyword($iY) Then
            $aMousePos = MouseGetPos()
            If IsKeyword($iX) Then $iX = $aMousePos[0]
            If IsKeyword($iY) Then $iY = $aMousePos[1]
        EndIf
    Else
        $aWinPos = WinGetPos($hWnd)
        $iX = $aWinPos[0] + $aWinPos[2]
        $iY = $aWinPos[1] + $aWinPos[3]
    EndIf

    ToolTip($sText, $iX, $iY, $sTitle, $iIcon, $iOptions)
    $__timer_ToolTipEx_Timeout = $iTimoutMS
    Switch $iTimout_IldeFaderMS
        Case 0
            $__timer_ToolTipEx_Idle = 0
            AdlibRegister("__ToolTipEx_KillSelf", $__timer_ToolTipEx_Timeout)
        Case Else
            $__timer_ToolTipEx_Idle = $iTimout_IldeFaderMS
            $__timer_ToolTipEx_Idle_Save = _Timer_GetIdleTime()
            AdlibRegister("__ToolTipEx_KillSelf", 100)
    EndSwitch
EndFunc   ;==>_ToolTipEx

Func __ToolTipEx_KillSelf()
    Switch $__timer_ToolTipEx_Idle
        Case 0
            ToolTip("")
            AdlibUnRegister("__ToolTipEx_KillSelf")
        Case Else
            $i_Timer_GetIdleTime = _Timer_GetIdleTime()
            If $i_Timer_GetIdleTime < $__timer_ToolTipEx_Idle_Save Then
                $__timer_ToolTipEx_Idle = 0
                AdlibRegister("__ToolTipEx_KillSelf", $__timer_ToolTipEx_Timeout)
                ;ConsoleWrite(TimerInit() & @TAB & "Timer #2" & @TAB & $__timer_ToolTipEx_Timeout & @TAB & $__timer_ToolTipEx_Idle & @TAB & $__timer_ToolTipEx & @CRLF)
            Else
                $__timer_ToolTipEx_Idle_Save = $i_Timer_GetIdleTime
                AdlibRegister("__ToolTipEx_KillSelf", 100)
                ;ConsoleWrite(TimerInit() & @TAB & "Timer #1" & @TAB & $__timer_ToolTipEx_Timeout & @TAB & $__timer_ToolTipEx_Idle & @TAB & $__timer_ToolTipEx & @CRLF)
            EndIf
    EndSwitch
    Return True
EndFunc   ;==>__ToolTipEx_KillSelf

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Link to comment
Share on other sites

Very Nice function KaFu, I really appreciate that you have shared this with me. Not only does it appear to be exactly what I need, but it opens many opportunities for me as well. This particular script, had me look more in depth at AdlibRegister() for the first time, which may be the answer to another dilemma I have been facing with a different project as well.

Thanks for taking the time to share this with me ;)

Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
Share on other sites

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...