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 

Button Tooltip

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





PostPosted: Fri Jul 31, 2009 7:36 pm    Post subject: Button Tooltip Reply with quote

Hi

I have a gui with a series of button and would like to add a ttoltip, so that when I hover over the buttons they explain there use a little more.

However, I cannot see any reference to this in the help.

Is this possible? Smile
Back to top
Relayer



Joined: 24 Nov 2008
Posts: 68

PostPosted: Fri Jul 31, 2009 8:26 pm    Post subject: Reply with quote

Right from the documentation for ControlGetPos:

; This working example will continuously update and display the
; name and position of the control currently under the mouse cursor:
Code:
Loop
{
    Sleep, 100
    MouseGetPos, , , WhichWindow, WhichControl
    ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow%
    ToolTip, %WhichControl%`nX%X%`tY%Y%`nW%W%`t%H%
}
Back to top
View user's profile Send private message
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Fri Jul 31, 2009 8:47 pm    Post subject: Reply with quote

Code:
Gui, +LastFound
Gui, Margin, 50, 50
Gui, Add, Button, hwndbtn1, Button1
Gui, Add, Button, hwndbtn2 x+50, Button2
Gui, Show,, Test
GuiHWND := WinExist()
Delay = 850

VarSetCapacity( HoverTime, 16, 0 )
NumPut( 16, HoverTime, 0, "UINT" )
NumPut( Delay, HoverTime, 12, "UINT" )

OnMessage(0x2A1, "WM_MOUSEHOVER")
OnMessage(0x200, "WM_MOUSEMOVE")
return

GuiClose:
Exitapp

WM_MOUSEHOVER(wparam, lparam, msg, hwnd)
{
   Global
   If ( A_GuiControl )
      Tooltip, You are hovering the mouse over %A_GuiControl%
   Else If ( previoushwnd = GuiHWND )
      Tooltip, You are hovering the mouse over the gui's client-area
   TooltipTime := A_TickCount + Delay
}

WM_MOUSEMOVE(wparam, lparam, msg, hwnd)
{
   Global HoverTime, previoushwnd, TooltipTime
   If ( A_TickCount > TooltipTime )
   {
      Tooltip,
      TooltipTime := 0x7FFFFFFFFFFFFFFF
      Reset = 1
   }
   If ( hwnd = previoushwnd ) && !Reset
      return
   NumPut( 0x80000000, HoverTime, 4, "UINT" )
   DllCall("TrackMouseEvent", UInt, &HoverTime )
   NumPut( 1, HoverTime, 4, "UINT" )
   NumPut( previoushwnd := hwnd, HoverTime, 8, "UINT" )
   DllCall("TrackMouseEvent", UInt, &HoverTime )
}
I'm not sure I can explain it adequately, but this is how to get a tooltip when hovering over something in a GUI.
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Last edited by [VxE] on Sun Aug 02, 2009 6:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
Newbie64
Guest





PostPosted: Sun Aug 02, 2009 1:09 pm    Post subject: Reply with quote

That's it VxE

However, I can't seem to work out how to assign different messages to each of the buttons

Thanks
Back to top
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Sun Aug 02, 2009 6:42 pm    Post subject: Reply with quote

I marked the important line in red. All you have to do is insert a bunch of if's right there, with different tooltips for each one. What you'll be checking in each 'if' is whether the variable A_GuiControl is equal to some string.
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
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