Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

ToolTip in Gui


  • Please log in to reply
3 replies to this topic
Hansol
  • Members
  • 36 posts
  • Last active: Aug 02 2011 07:31 PM
  • Joined: 27 Dec 2005
Hi!
The example shows a tooltip when I hover over an edit control. Is it possible to get a tooltip when I hover over a text control in a gui?

Gui, Add, Edit, vMyEdit
MyEdit_TT := "A tooltip"

Gui, Add, Text, vMyText, Sometext    ;???
MyText_TT := "A tooltip"                   ;???

Gui, Add, DropDownList, vMyDDL, Red|Green|Blue
MyDDL_TT := "Choose a color from the drop-down list."

Gui, Show

OnMessage(0x200, "WM_MOUSEMOVE")

return


WM_MOUSEMOVE()
{
    static CurrControl, PrevControl, _TT  ; _TT is kept blank for use by the ToolTip command below.
    CurrControl := A_GuiControl
    If (CurrControl <> PrevControl and not InStr(CurrControl, " "))
    {
        ToolTip  ; Turn off any previous tooltip.
        SetTimer, DisplayToolTip, 1000
        PrevControl := CurrControl
    }
    return

    DisplayToolTip:
    SetTimer, DisplayToolTip, Off
    ToolTip % %CurrControl%_TT  ; The leading percent sign tell it to use an expression.
    SetTimer, RemoveToolTip, 3000
    return

    RemoveToolTip:
    SetTimer, RemoveToolTip, Off
    ToolTip
    return
}

GuiClose:
ExitApp


jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
Here's a simpler example to learn from.
Gui, Add, Text, w400, Show me a ToolTip!

SetTimer, ToolTip



Gui, Show

return

GuiClose:

ExitApp



ToolTip:

MouseGetPos,,,,control

If (control = "static1") AND !(on)

{

 ToolTip, Here it is.

 on = 1

}

Else If (control != "static1") AND (on)

{

 ToolTip

 on = 0

}

return


Dra_Gon
  • Members
  • 373 posts
  • Last active: Oct 27 2009 04:20 PM
  • Joined: 25 May 2007
Going along with jaco0646's example, you can make variables which are control-specific. Here's what I mean:

Gui, Add, Text, w400, Show me a ToolTip!
SetTimer, ToolTip

Gui, Show, , MyGUI

var_Static1 = This is a ToolTip for Static 1 - a TextBox ; Put this at the top along with any others you want to try.

return
GuiClose:
ExitApp

ToolTip:
MouseGetPos,,,,control
tmpVar := var_%control%
ToolTip, %tmpVar%
; Doing this you will have to make sure you know what the ClassNN of the controls you want to use a ToolTip for

; And if you have multiple GUI's you can use the lines below in place of the 3 above and the associated variable:

;  These 2 go above -  in place of the "var_Static1":
;  WinGet, thisGUI,, MyGUI  ;<-- This is to get the GUI's Unique ID - it needs to go AFTER each GUI is created
;  var_%thisGUI%_Static1 = This is a ToolTip for MyGUI's Static 1!

;  And these below:
;  MouseGetPos,,,tGUI,control
;  tmpVar := var_%tGUI%_%control%
;  ToolTip, %tmpVar%

return

It's a little bit more complicated, but will look pretty good. I just tested both ways so they work if you want them.

Ciao,
Dra'Gon
Posted Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writersca...BlueDragonFire/

Hansol
  • Members
  • 36 posts
  • Last active: Aug 02 2011 07:31 PM
  • Joined: 27 Dec 2005
Thanks for the replies. I think the problem is solved. The "dynamic" feature was what I needed since I take the text and var_Static from a text file and they can be many. Many Thanks.

text1 = Show me ToolTip1!
text2 = Show me ToolTip2!
text3 = Show me ToolTip3!

var_Static1 = ToolTip1!
var_Static2 = ToolTip2!
var_Static3 = ToolTip3!

Loop, 3
  Gui, Add, Text, w200, text%A_Index%

SetTimer, ToolTip

Gui, Show, , MyGUI

return
GuiClose:
ExitApp

ToolTip:
MouseGetPos,,,,control
tmpVar := var_%control%
ToolTip, %tmpVar%
return