AutoHotkey Community

It is currently May 27th, 2012, 6:47 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: May 12th, 2009, 1:59 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Hi Superfraggle, we've got one small issue/problem.

If only 1 Control is associated with ToolTip, ToolTip will not pop up again after it has been hidden by system (not by mouse movements)

Any ideas?
Code:
; ### Example Code #####
Gui,Add,Button,hwndbutton1,Test Button 1
AddTooltip(button1,"Press me to change my tooltip")
Gui,show,,Test Gui
Return
GuiClose:
Guiescape:
Exitapp

; ### End Example Code #####

AddToolTip(con,text,Modify = 0){
  Static TThwnd,GuiHwnd
  If (!TThwnd){
    Gui,+LastFound
    GuiHwnd:=WinExist()
    TThwnd:=CreateTooltipControl(GuiHwnd)
  }
  Varsetcapacity(TInfo,44,0)
  Numput(44,TInfo)
  Numput(1|16,TInfo,4)
  Numput(GuiHwnd,TInfo,8)
  Numput(con,TInfo,12)
  Numput(&text,TInfo,36)
  Detecthiddenwindows,on
  If (Modify){
    SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
  }
  Else {
    Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
    SendMessage,1048,0,300,,ahk_id %TThwnd%
  }
 
}

CreateTooltipControl(hwind){
  Ret:=DllCall("CreateWindowEx"
          ,"Uint",0
          ,"Str","TOOLTIPS_CLASS32"
          ,"Uint",0
          ,"Uint",2147483648 | 3
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",hwind
          ,"Uint",0
          ,"Uint",0
          ,"Uint",0)
         
  Return Ret
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2009, 9:05 pm 
Offline

Joined: June 1st, 2009, 8:59 pm
Posts: 5
Location: Germany
first to say: thanks for that feature :)

but I have one problem:
I want to set a tooltip for an edit-box, which is disabled.
How do I do that? It only shows the tooltip, when it is enabled again.


bye,
Tilex


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2009, 10:20 pm 
Offline

Joined: November 2nd, 2004, 2:43 pm
Posts: 1019
Location: London, UK
HotKeyIt,

Sorry about the delay in getting back to you, I have not been on the forum for a while. Not sure what you mean there.
If you mean let the tooltip close itself, then move mouse to bring it back. If I move the mouse off the control and back on the tooltip reappears.

I am on vista, so that could be an XP bug.

Tilex,

I believe that is standard windows and cannot be bypassed, you would have to write custom tooltips as suggested in the manual.

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 4th, 2009, 10:36 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Superfraggle wrote:
HotKeyIt,

Sorry about the delay in getting back to you, I have not been on the forum for a while. Not sure what you mean there.
If you mean let the tooltip close itself, then move mouse to bring it back. If I move the mouse off the control and back on the tooltip reappears.

I am on vista, so that could be an XP bug.


Try this, do not move your mouse until the ToolTip disappears and it will not come back.
I fixed this already in ToolTip() by adding a tool for Gui hWnd, give it a try, many thanks to you.
Code:

; ### Example Code #####
Gui,Add,Button,hwndbutton1 Gbut1,Test Button 1
AddTooltip(button1,"Press me to change my tooltip")
Gui,show,,Test Gui
Return

But1:
AddTooltip(button1,"Wasn't that easy `;)",1)
REturn

GuiClose:
Guiescape:
Exitapp

; ### End Example Code #####

AddToolTip(con,text,Modify = 0){
  Static TThwnd,GuiHwnd
  If (!TThwnd){
    Gui,+LastFound
    GuiHwnd:=WinExist()
    TThwnd:=CreateTooltipControl(GuiHwnd)
  }
  Varsetcapacity(TInfo,44,0)
  Numput(44,TInfo)
  Numput(1|16,TInfo,4)
  Numput(GuiHwnd,TInfo,8)
  Numput(con,TInfo,12)
  Numput(&text,TInfo,36)
  Detecthiddenwindows,on
  If (Modify){
    SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
  }
  Else {
    Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
    SendMessage,1048,0,300,,ahk_id %TThwnd%
  }
 
}

CreateTooltipControl(hwind){
  Ret:=DllCall("CreateWindowEx"
          ,"Uint",0
          ,"Str","TOOLTIPS_CLASS32"
          ,"Uint",0
          ,"Uint",2147483648 | 3
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",hwind
          ,"Uint",0
          ,"Uint",0
          ,"Uint",0)
         
  Return Ret
}


Fix for your function:
Code:

; ### Example Code #####
Gui,Add,Button,hwndbutton1 Gbut1,Test Button 1
AddTooltip(button1,"Press me to change my tooltip")
Gui,show,,Test Gui
Return

But1:
AddTooltip(button1,"Wasn't that easy `;)",1)
REturn

GuiClose:
Guiescape:
Exitapp

; ### End Example Code #####

AddToolTip(con,text,Modify = 0){
  Static TThwnd,GuiHwnd
  If (!TThwnd){
    Gui,+LastFound
    GuiHwnd:=WinExist()
    TThwnd:=CreateTooltipControl(GuiHwnd)
   Varsetcapacity(TInfo,44,0)
   Numput(44,TInfo)
   Numput(1|16,TInfo,4)
   Numput(GuiHwnd,TInfo,8)
   Numput(GuiHwnd,TInfo,12)
   ;Numput(&text,TInfo,36)
   Detecthiddenwindows,on
   Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
    SendMessage,1048,0,300,,ahk_id %TThwnd%
  }
  Varsetcapacity(TInfo,44,0)
  Numput(44,TInfo)
  Numput(1|16,TInfo,4)
  Numput(GuiHwnd,TInfo,8)
  Numput(con,TInfo,12)
  Numput(&text,TInfo,36)
  Detecthiddenwindows,on
  If (Modify){
    SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
  }
  Else {
    Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
    SendMessage,1048,0,300,,ahk_id %TThwnd%
  }
 
}

CreateTooltipControl(hwind){
  Ret:=DllCall("CreateWindowEx"
          ,"Uint",0
          ,"Str","TOOLTIPS_CLASS32"
          ,"Uint",0
          ,"Uint",2147483648 | 3
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",-2147483648
          ,"Uint",hwind
          ,"Uint",0
          ,"Uint",0
          ,"Uint",0)
         
  Return Ret
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2011, 1:40 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
Here's a working version for AHK_L Unicode (x64 untested so far, but should work)
Code:
AddToolTip(con,text,Modify = 0)
{
   Static TThwnd,GuiHwnd
   l_DetectHiddenWindows:=A_DetectHiddenWindows
   If (!TThwnd)
   {
      Gui,+LastFound
      GuiHwnd:=WinExist()
      TThwnd:=CreateTooltipControl(GuiHwnd)
      Varsetcapacity(TInfo,6*4+6*A_PtrSize,0)
      Numput(6*4+6*A_PtrSize,TInfo, "UInt")
      Numput(1|16,TInfo,4, "UInt")
      Numput(GuiHwnd,TInfo,8, "PTR")
      Numput(GuiHwnd,TInfo,8+A_PtrSize, "PTR")
      ;Numput(&text,TInfo,36)
      Detecthiddenwindows,on
      Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
      SendMessage,1048,0,300,,ahk_id %TThwnd%
   }
   Varsetcapacity(TInfo,6*4+6*A_PtrSize,0)
   Numput(6*4+6*A_PtrSize,TInfo, "UInt")
   Numput(1|16,TInfo,4, "UInt")
   Numput(GuiHwnd,TInfo,8, "PTR")
   Numput(con,TInfo,8+A_PtrSize, "PTR")
   VarSetCapacity(ANSItext, StrPut(text, ""))
    StrPut(text, &ANSItext, "")
   Numput(&ANSIText,TInfo,6*4+3*A_PtrSize, "PTR")

   Detecthiddenwindows,on
   If (Modify)
      SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
   Else {
      Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
      SendMessage,1048,0,300,,ahk_id %TThwnd%
   }
   DetectHiddenWindows %l_DetectHiddenWindows%
}
CreateTooltipControl(hwind)
{
   Ret:=DllCall("CreateWindowEx"
   ,"Uint",0
   ,"Str","TOOLTIPS_CLASS32"
   ,"PTR",0
   ,"Uint",2147483648 | 3
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"PTR",hwind
   ,"PTR",0
   ,"PTR",0
   ,"PTR",0, "PTR")
   Return Ret
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2011, 1:06 pm 
fragman, your version doesn't work for unicode characters. Tested on AHK_L 1.1.00.00 unicode. Can you fix it? Test:
Code:
Gui,Add,Button,hwndbutton1, Test Button 1
AddTooltip(button1,"Ж.И.`nЮ.Щ.")
Gui,show,,Test Gui
Return

GuiClose:
Exitapp

AddToolTip(con,text,Modify = 0)
{
   Static TThwnd,GuiHwnd
   l_DetectHiddenWindows:=A_DetectHiddenWindows
   If (!TThwnd)
   {
      Gui,+LastFound
      GuiHwnd:=WinExist()
      TThwnd:=CreateTooltipControl(GuiHwnd)
      Varsetcapacity(TInfo,6*4+6*A_PtrSize,0)
      Numput(6*4+6*A_PtrSize,TInfo, "UInt")
      Numput(1|16,TInfo,4, "UInt")
      Numput(GuiHwnd,TInfo,8, "PTR")
      Numput(GuiHwnd,TInfo,8+A_PtrSize, "PTR")
      ;Numput(&text,TInfo,36)
      Detecthiddenwindows,on
      Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
      SendMessage,1048,0,300,,ahk_id %TThwnd%
   }
   Varsetcapacity(TInfo,6*4+6*A_PtrSize,0)
   Numput(6*4+6*A_PtrSize,TInfo, "UInt")
   Numput(1|16,TInfo,4, "UInt")
   Numput(GuiHwnd,TInfo,8, "PTR")
   Numput(con,TInfo,8+A_PtrSize, "PTR")
   VarSetCapacity(ANSItext, StrPut(text, ""))
    StrPut(text, &ANSItext, "")
   Numput(&ANSIText,TInfo,6*4+3*A_PtrSize, "PTR")

   Detecthiddenwindows,on
   If (Modify)
      SendMessage,1036,0,&TInfo,,ahk_id %TThwnd%
   Else {
      Sendmessage,1028,0,&TInfo,,ahk_id %TThwnd%
      SendMessage,1048,0,300,,ahk_id %TThwnd%
   }
   DetectHiddenWindows %l_DetectHiddenWindows%
}
CreateTooltipControl(hwind)
{
   Ret:=DllCall("CreateWindowEx"
   ,"Uint",0
   ,"Str","TOOLTIPS_CLASS32"
   ,"PTR",0
   ,"Uint",2147483648 | 3
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"Uint",-2147483648
   ,"PTR",hwind
   ,"PTR",0
   ,"PTR",0
   ,"PTR",0, "PTR")
   Return Ret
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 28th, 2011, 5:15 pm 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I know, I'm explicitly converting it to ANSI because the tooltips didn't work with the Unicode version of AHK_L. There might be Unicode versions of the messages used for the tooltip controls, but I don't know about them. Feel free to look them up on MSDN and post a working version :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2011, 9:39 am 
Offline

Joined: September 23rd, 2008, 3:37 am
Posts: 49
[ AHK, AHK_L compatible ]

Code:

;================================================================================
AddToolTip(CtrlHwnd,text,Modify=0) {   ; ***** Add Multiline ToolTips to any Gui Control *****                       [ AHK, AHK_L compatible ]
   Static TThwnd, GuiHwnd, Ptr   ; - 'Text' and 'Picture' Controls requires a g-label to be defined.
   If (!TThwnd){         ; - 'ComboBox' = Drop-Down button + Edit (Get hWnd of the 'Edit'   control using "ControlGet" command).
      Gui,+LastFound      ; - 'ListView' = ListView + Header       (Get hWnd of the 'Header' control using "ControlGet" command).
      GuiHwnd:=WinExist()
      TThwnd:=DllCall("CreateWindowEx","Uint",0,"Str","TOOLTIPS_CLASS32","Uint",0,"Uint",2147483648 | 3,"Uint",-2147483648
         ,"Uint",-2147483648,"Uint",-2147483648,"Uint",-2147483648,"Uint",GuiHwnd,"Uint",0,"Uint",0,"Uint",0)
      Ptr:=(A_PtrSize ? "Ptr" : "UInt"), DllCall("uxtheme\SetWindowTheme","Uint",TThwnd,Ptr,0,"UintP",0)   ; TTM_SETWINDOWTHEME
   }
   Varsetcapacity(TInfo,44,0), Numput(44,TInfo), Numput(1|16,TInfo,4), Numput(GuiHwnd,TInfo,8), Numput(CtrlHwnd,TInfo,12), Numput(&text,TInfo,36)
   !Modify   ? (DllCall("SendMessage",Ptr,TThwnd,"Uint",1028,Ptr,0,Ptr,&TInfo,Ptr))         ; TTM_ADDTOOL = 1028 (used to add a tool, and assign it to a control)
      . (DllCall("SendMessage",Ptr,TThwnd,"Uint",1048,Ptr,0,Ptr,A_ScreenWidth))      ; TTM_SETMAXTIPWIDTH = 1048 (This one allows the use of multiline tooltips)
   DllCall("SendMessage",Ptr,TThwnd,"UInt",(A_IsUnicode ? 0x439 : 0x40c),Ptr,0,Ptr,&TInfo,Ptr)   ; TTM_UPDATETIPTEXT (OLD_MSG=1036) (used to adjust the text of a tip)
}



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2011, 10:47 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I see you used A_IsUnicode in the Sendmessage call, so I suppose it supports Unicode now?

I noticed that tooltips won't show on DropDownLists/Comboboxes, any idea why?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2011, 11:28 am 
Offline

Joined: September 23rd, 2008, 3:37 am
Posts: 49
@fragman

The function i post at http://www.autohotkey.com/forum/viewtopic.php?t=30300&p=452514#452514 is working for all controls created using
- jballi's example posted at http://www.autohotkey.com/forum/viewtopic.php?t=30300&p=267487#267487 and
- uni guest's example posted at http://www.autohotkey.com/forum/viewtopic.php?t=30300&p=447939#447939.

Tested on Windows XP-SP3 and Windows 7 with both AHK 1.0.48.05 and AHK_L 1.0.92.02.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 29th, 2011, 6:00 pm 
how would I extend the time the tooltip shows itself?

after sorting through several different approaches to create a basic tooltip method for just text labels in a gui this one seems simpler than most (thanks to art for the ahk_L validation) however it seems to be only 5 seconds and the tip closes itself

thanks a lot


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2011, 8:01 am 
Offline

Joined: September 23rd, 2008, 3:37 am
Posts: 49
@Astrid
The notification's display time is a windows feature.
To change the time globally for windows follow this guide: Increase Windows 7 Notifiction Display Time


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2011, 9:47 am 
hi, i tested the thread first post and got this result, can somebody explain, why it only shows the first letter ?

Image

i am using AHK_L latest version and Windows XP 32bit


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 4th, 2011, 10:01 am 
please delete my last post, thanks


Report this post
Top
  
Reply with quote  
 Post subject: A little help please
PostPosted: November 12th, 2011, 11:04 pm 
Offline

Joined: September 17th, 2011, 5:44 am
Posts: 16
OK, I finally got this script to work for me, but when I hover for a tooltip, it only shows the first letter (much like the last post, and he didnt leave a fix lol)

Can someone tell me where I need to look?

Thanks, Terry


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, jepjep24, Yahoo [Bot] and 20 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