Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHL_L/v2] TT() - Full-blown ToolTip Library


  • Please log in to reply
197 replies to this topic
dysmas
  • Members
  • 63 posts
  • Last active: Apr 06 2011 11:01 AM
  • Joined: 28 Dec 2010
Hello, HotKeyIt,
here are the results of the tests :

Vista 32 and Win7 32 :
Tooltip position correct if tray icon visible
Tooltip at mouse position if tray icon not visible.

I think this is normal, and you could add a default if the tray icon is not visible (and position returns 0,0). Something like :

If (!xc && !yc)
{
       xc := A_ScreenWidth - 10
       yc := A_ScreenHeight - 10
}

In Win7 64 bits the tooltip is always at mouse position
Vista 64 bits is untested because we don't have it.

This is not a big issue.

Thanks for this code.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks dysmas, I will take a look.

But I dont have skills to do that...
Could be great to have w and h options for the icon... in TT funtion.

Thanks a lot.

Here is an example how you could load a picture onto ToolTip using AniGif, shajul kindly converted to AHK_L
TT:=TT()
 TT.SetMargin(100)
 gHwnd:=AniGif_CreateControl(TT.hwnd, 0, 0, 100, 100)
 WideCharToMultiByte("hal-1.gif",sFile)
 AniGif_LoadGifFromFile(gHwnd,sFile)
 TT.Show("Hello","","","AutoHotkey")
 MsgBox Exiting now
 Exitapp


dysmas
  • Members
  • 63 posts
  • Last active: Apr 06 2011 11:01 AM
  • Joined: 28 Dec 2010
I worked a little on your script to understand.
About the default value if the trayIcon position cannot be reported, I thought of three possible solutions, each one easy to implement :

1) right side of the screen, just above the system tray (I have implemented this inside my own program presently. Not very clean code, you would do something better. The question is : we must get the height of the tooltip before it is displayed. I don't know how to do that, so I display it, get the height and cancel it at once with T.Text(""), then redisplay with correct position).
2) if the tooltip is a balloon, a good choice could be also the top left angle of the system tray.
3) A third interesting option would be to separate the code which looks for the tray icon position in a separate function, so that the user can first check for this position, and depending of the result, will choose the solution for his tooltip. Probably the most flexible option.

quinxy
  • Members
  • 30 posts
  • Last active: Dec 27 2011 01:04 AM
  • Joined: 17 May 2010
Okay, this is going to sound crazy, but here's what I'm seeing.

I run the demo provided and all is well, the tray tips appear as they should.

I take the exact same code, and insert it in the beginning of my script and now the tray tip title works but every line after it is a big, random number.

For the first demo I'll see:

Title
3948039201

I run it again and now it might be:

Title
983202384

Obviously I started trying to use the code as one would but once I saw this I inserted the example code at the start of my script, disabling other things in my script so it would work and this weird behavior continues...

I don't see how anything could be conflicting... Anyone have any ideas? Running everything with AutoHotKey_L on Windows 7 (running AHK as x86).

I'm literally going insane trying to figure this out.

Or if you can't help me on this point, does anyone know how to assign a subroutine to the clicking of the built-in TrayTip? It seems there's nothing in the API, which I suppose might have encouraged the development of this alternative.

Thanks!

Q

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Have you got the latest Struct() function? This looks like Struct_getVar() does not work.
Are you using Win7 64-bit running AHK in compatibility mode x86?

Try this to detect click on TrayTip.
OnMessage(0x400+4,"TB_HIDEBUTTON")
TrayTip,AutoHotkey,Click Me,10
Return
TB_HIDEBUTTON(wParam,lParam,msg,hwnd){
	If lParam=1029
	{
		MsgBox TrayTip Click`, AutoHotkey will now exit
		ExitApp
	}
}


dysmas
  • Members
  • 63 posts
  • Last active: Apr 06 2011 11:01 AM
  • Joined: 28 Dec 2010
If you are going mad debugging this issue, have you try with a real IDE ? You can go step by step, see if your variable is OK wen T. is called and so on. You will find the problem in 15 minutes and this will pay for the time you will need to install Dev-PHP and get used to it.

If you want an example of the tooltips working :
<!-- m -->http://unichars.sourceforge.net<!-- m -->
You have the sources. Unichars uses the tooltips heavily.


the full story of AHK in Dev-PHP is found here :
<!-- m -->http://www.autohotke... ... c&start=30<!-- m -->

the important post is the following one (sorry I don't know how to link to a particular post) :

================================

Dev-PHP with AHK support is online at
<!-- m -->http://devphp.sourceforge.net/<!-- m -->
You must take the Exp version (2.5.0.348) and the first time you MUST use the installer. After that, you can just pick the exe when a new version arrives.


What you get in this version :
Syntax highlighting
Xdebug works fine
View variables in a tooltip, or in the watch list.
You can organize your script with named bookmarks. See the documentation here :
<!-- m -->http://sourceforge.n... ... _Bookmarks<!-- m -->

What is not implemented yet :
The names of functions are not yet present in the function list. This is the next step.

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009
Thanks a lot for wrapping this HotKeyIt. Most likely from too much copy/paste:

Bug:
TTM_SETDELAYTIME(T,whichTime=0,mSec=-1){
	;TTDT_AUTOMATIC = 0; TTDT_RESHOW = 1; TTDT_AUTOPOP = 2; TTDT_INITIAL = 3
   static TTM_SETDELAYTIME = 0x400 + 3
   Return DllCall("SendMessage","UPTR",T.HWND,"UInt",TTM_SETDELAYTIME,"UPTR",[color=red]0[/color],"UPTR",mSec,"UPTR")
}
Fix:
TTM_SETDELAYTIME(T,whichTime=0,mSec=-1){
	;TTDT_AUTOMATIC = 0; TTDT_RESHOW = 1; TTDT_AUTOPOP = 2; TTDT_INITIAL = 3
   static TTM_SETDELAYTIME = 0x400 + 3
   Return DllCall("SendMessage","UPTR",T.HWND,"UInt",TTM_SETDELAYTIME,"UPTR",[color=red]whichTime[/color],"UPTR",mSec,"UPTR")
}


HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thank you, this is fixed now :)

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009
HotKeyIt, I have a weird issue that I have been unable to debug in my main script (which is far too big to post). When the following code is executed, the tooltip's title shows without any problem, but, the text reads the pointer to the text instead of the actual text:
TT := TT("","text here","title here")
TT.Show()
Result: Posted Image

I have checked the memory and confirmed that the text string is at the address pointed to by the tooltip, but the tooltip text only shows the pointer. Any idea why this would be happening?

Tested same on AHK_L 32-bit ANSI and Unicode. I apologize that I can't provide an example of this problem as I've been unable to reproduce it outside of my main script. When I test the code outside my main script, it works as expected.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
So does it happen when you run just this piece of code?
Are you using latest Struct.ahk?

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009

So does it happen when you run just this piece of code?

In a small example script, it works as expected. In the script I'm currently developing (which is thousands of lines), it has the problem.

Are you using latest Struct.ahk?

Yes. Also, when trying to debug, AHK_L crashes at Struct_getVar. Not sure if this is relevant. It does however make it hard for me to find whatever is causing this problem.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Can you upload your script and send me a link via pm?

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009

Can you upload your script and send me a link via pm?

Sure. I'll upload it and give you a PM when I get back on my work system.

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009
I figured it out. Any instance of SetFormat, Integer will cause this to happen. Example:

#Include struct.ahk
#Include tt.ahk

SetFormat, Integer, D
;SetFormat, Integer, H ; or this

TT := TT("","text here","title here")
TT.Show()
I noticed that IntegerFast does not cause this problem.

Solar
  • Members
  • 345 posts
  • Last active: Jan 15 2012 08:11 PM
  • Joined: 03 May 2009
One more thing: ToolTip.Add() won't work with static (text, picture) controls. Is this a bug or a limitation?

Edit: Figured this out as well. Add 0x100 to the static's Gui control options to enable the SS_NOTIFY style. You might want to include this in the documentation.