AutoHotkey Community

It is currently May 26th, 2012, 12:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ToolTip in Gui
PostPosted: December 14th, 2008, 9:14 pm 
Offline

Joined: December 27th, 2005, 2:28 pm
Posts: 36
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?

Code:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 9:32 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Here's a simpler example to learn from.
Code:
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 11:12 pm 
Offline

Joined: May 25th, 2007, 6:13 pm
Posts: 373
Going along with jaco0646's example, you can make variables which are control-specific. Here's what I mean:

Code:
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

_________________
Image
For a good laugh {hopefully} >> megamatts.50megs.com

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 11:50 pm 
Offline

Joined: December 27th, 2005, 2:28 pm
Posts: 36
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.

Code:
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Morpheus and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group