AutoHotkey Community

It is currently May 26th, 2012, 9:23 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Button Tooltip
PostPosted: July 31st, 2009, 8:36 pm 
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? :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2009, 9:26 pm 
Offline

Joined: November 24th, 2008, 7:22 pm
Posts: 73
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%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2009, 9:47 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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 August 2nd, 2009, 7:38 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2009, 2:09 pm 
That's it VxE

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

Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 2nd, 2009, 7:42 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
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!


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, wolverineks and 63 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