Sign in to follow this  
Followers 0
saywell

GUI Tooltips

13 posts in this topic

Hi,

I'd like to have a tooltip appear with help info, when the mouse hovers over a button on my GUI.

I don't want to spend time and write loads of code checking mouse position against gui position, as the game wouldn't be worth the candle. However, I've found this UDF - GuiToolTip.au3 which looks as though it might do what I want. Unfortunately, there are no examples of code to look at/run in the helpfile, nor any hits on searching the forum for GuiToolTip.au3 or _GUIToolTip.

Before I waste any time trying it out, can anyone confirm that this will do what I want, or, conversely, that I barking up completely the wrong tree?

Regards,

William [note I'm not asking for code to be written for me!]

Share this post


Link to post
Share on other sites



Run this, and hover over the button.

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("GUITooltip", 147, 94)
$btnMe = GUICtrlCreateButton("Hover over me!", 16, 24, 113, 49)
GUICtrlSetTip($btnMe, "Look, you hovered over me!")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

James

Share this post


Link to post
Share on other sites

Run this, and hover over the button.

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("GUITooltip", 147, 94)
$btnMe = GUICtrlCreateButton("Hover over me!", 16, 24, 113, 49)
GUICtrlSetTip($btnMe, "Look, you hovered over me!")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

James

James,

many thanks indeed.

that's so easy I don't know how I failed to discover it - I'd been looking in areas of excessive complexity and missed the simple one!

Every day i seem to learn something new whilst creating my program.

Regards,

William

Share this post


Link to post
Share on other sites

One more query:

I've put some tooltips into my GUI, which is running OnEvent Mode.

When i hover, they appear, then disappear when I move away, and return when I hover again [so far, so good].

If I keep hovering, they seem to time out - and intermittent hovering also seems to have a cumulative total before disappearing!

if I click the button/input it seems to reset the clock!

is this intended behaviour, or have I done something wrong? If the former, can the timeout be varied with a style or similar?

Thanks,

William

Share this post


Link to post
Share on other sites

is this intended behaviour, or have I done something wrong? If the former, can the timeout be varied with a style or similar?

Intended. Without creating your own tooltip, I doubt there is an easy and elegant way of displaying the tooltips for longer.

I believe however, that the time they display for is appropriate and it's common Windows behaviour for the user just to be able to hover back over for them again.

James

Share this post


Link to post
Share on other sites

Thanks, James.

I'll take what Bill Gates prescribes, as I don't want to get into anything too complicated!

William

Share this post


Link to post
Share on other sites

While on the subject of tooltips, why are they slow appearing? If this is an attribute of AU3, does anyone have a snippet of a DllCall that works with AU3? Thanks...


“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites

While on the subject of tooltips, why are they slow appearing? If this is an attribute of AU3, does anyone have a snippet of a DllCall that works with AU3? Thanks...

This is either Windows behaviour although I believe you can pragmatically define how long a tooltip takes to appear if you're drawing it yourself (which AutoIt does) which must mean that either AutoIt has defined the length it takes, or Windows has decided it for you.

Share this post


Link to post
Share on other sites

This is either Windows behaviour although I believe you can pragmatically define how long a tooltip takes to appear if you're drawing it yourself (which AutoIt does) which must mean that either AutoIt has defined the length it takes, or Windows has decided it for you.

I have been working a little with AHK and their tip comes up immediately.

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites

I have been working a little with AHK and their tip comes up immediately.

I may have mislead on this one. The actual command is "GUICtrlSetTip" that is slow, not "Tooltip"

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites

Example?

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>

#cs
 If user fuctions are in play, use one of the following to prevent Obfuscator from deleting them.

 Example 1.
 #Obfuscator_Ignore_Funcs=_UpdateStatusBarClock,_UpdateProgressBar

 Example 2.
 If 0 Then _UpdateStatusBarClock(0, 0, 0, 0)
 If 0 Then _UpdateProgressBar(0, 0, 0, 0)
#ce

; Disable window close with Alt+F4 and Esc
HotKeySet ("!{F4}","test")  ; Must be directed to a function test().
opt("GuiCloseOnEsc", 0)
_Main()

Func _Main()
    Local $msg, $GUIWidth = 500, $GUIHeight = 500
    Global $Button, $hButton, $hWin
    ; Create main/parent window
    $ParentWin = GUICreate("Parent GUI", $GUIWidth, $GUIHeight)
    ; Create controls.
    $Button = GUICtrlCreateButton("Button", 50, 50)
GUICtrlSetTip($Button, "Look, you hovered over me!")
    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $Button
                ; Get control's handles.
GUICtrlSetTip($Button, "Loading!")
                $hWin = WinGetHandle("Parent GUI")
                $hButton = ControlGetHandle ( "", "Button", "Button1" )
                MsgBox(64, "Test", $hButton & @CRLF & $hWin)
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
        EndSelect
    WEnd
EndFunc

Func test()
    ;MsgBox(64,0,"testing f4")
EndFunc

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
Share on other sites

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <GUIConstantsEx.au3>

#cs
 If user fuctions are in play, use one of the following to prevent Obfuscator from deleting them.

 Example 1.
 #Obfuscator_Ignore_Funcs=_UpdateStatusBarClock,_UpdateProgressBar

 Example 2.
 If 0 Then _UpdateStatusBarClock(0, 0, 0, 0)
 If 0 Then _UpdateProgressBar(0, 0, 0, 0)
#ce

; Disable window close with Alt+F4 and Esc
HotKeySet ("!{F4}","test")  ; Must be directed to a function test().
opt("GuiCloseOnEsc", 0)
_Main()

Func _Main()
    Local $msg, $GUIWidth = 500, $GUIHeight = 500
    Global $Button, $hButton, $hWin
    ; Create main/parent window
    $ParentWin = GUICreate("Parent GUI", $GUIWidth, $GUIHeight)
    ; Create controls.
    $Button = GUICtrlCreateButton("Button", 50, 50)
GUICtrlSetTip($Button, "Look, you hovered over me!")
    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $Button
                ; Get control's handles.
GUICtrlSetTip($Button, "Loading!")
                $hWin = WinGetHandle("Parent GUI")
                $hButton = ControlGetHandle ( "", "Button", "Button1" )
                MsgBox(64, "Test", $hButton & @CRLF & $hWin)
            Case $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
        EndSelect
    WEnd
EndFunc

Func test()
    ;MsgBox(64,0,"testing f4")
EndFunc

I put this together right after my last post, but I was waiting to see if you would reply. This one works very well - no flicker and fast:
Local $ctrl, $ID
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
        $ID = GUIGetCursorInfo()
        If $ID[4] <> $ctrl then
            Tooltip($tip[$ID[4]])
            $ctrl = $ID[4]
        EndIf
    WEnd
I am not that good at "C", so if you come up with a resolve, I am still interested. Thanks....

“No other God have I but Thee; born in a manger, died on a tree.” Martin Luther

Share this post


Link to post
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
Sign in to follow this  
Followers 0