AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ToolTip in Gui

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Hansol



Joined: 27 Dec 2005
Posts: 36

PostPosted: Sun Dec 14, 2008 8:14 pm    Post subject: ToolTip in Gui Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
jaco0646



Joined: 07 Oct 2006
Posts: 3113
Location: MN, USA

PostPosted: Sun Dec 14, 2008 8:32 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Dra_Gon



Joined: 25 May 2007
Posts: 373

PostPosted: Sun Dec 14, 2008 10:12 pm    Post subject: Reply with quote

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
_________________

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

My WritersCafe profile>>
http://www.writerscafe.org/writers/BlueDragonFire/
Back to top
View user's profile Send private message Send e-mail
Hansol



Joined: 27 Dec 2005
Posts: 36

PostPosted: Sun Dec 14, 2008 10:50 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group