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
HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Yes for TT I use PTR, the other functions do not so you will need to adapt before testing.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I got BalloonTip to work, except for some string issues I didn't check out:
#Persistent
BalloonTip("This is a BalloonTip Test.")

BalloonTip(sText, sTitle = "AutoHotkey")
{
   hWnd := DllCall("CreateWindowEx", "Uint", 0x8, "str", "tooltips_class32", "str", "", "Uint", 0xC3, "int", 0, "int", 0, "int", 0, "int", 0, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Ptr")
   DllCall("GetCursorPos", "int64P", pt)
   xCursor := pt << 32 >> 32            ; can be negative
   yCursor := pt       >> 32            ; can be negative
   hDCScr  := DllCall("GetDC", "Ptr", 0, "Ptr")
   nColor  := DllCall("GetPixel", "Ptr", hDCScr, "int", xCursor, "int", yCursor)
   DllCall("ReleaseDC", "Ptr",0, "Ptr", hDCScr)

   VarSetCapacity(ti, 28 + A_PtrSize * 3, 0)
   ti := Chr(28 + A_PtrSize * 3)
   DllCall("ntdll\RtlFillMemoryUlong", "Ptr", &ti + 4, "Uint", 4, "Uint", 0x20)   ; TTF_TRACK
   NumPut(&sText,&ti,24+A_PtrSize*3)
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1028, "Ptr", 0, "Ptr", &ti, "Ptr")   ; TTM_ADDTOOL
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1041, "Ptr", 1, "Ptr", &ti, "Ptr")   ; TTM_TRACKACTIVATE
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1042, "Ptr", 0, "Ptr", (xCursor & 0xFFFF)|(yCursor & 0xFFFF)<<16, "Ptr")   ; TTM_TRACKPOSITION
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1043, "Ptr", nColor, "Ptr", 0, "Ptr")   ; TTM_SETTIPBKCOLOR
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1044, "Ptr", ~nColor & 0xFFFFFF, "Ptr", 0, "Ptr")   ; TTM_SETTIPTEXTCOLOR
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1056, "Ptr", 1, "Ptr", &sTitle, "Ptr")   ; TTM_SETTITLE   ; 0: None, 1:Info, 2: Warning, 3: Error. n > 3: assumed to be an hIcon.
   DllCall("SendMessage", "Ptr", hWnd, "Uint", 1036, "Ptr", 0, "Ptr", &ti, "Ptr")   ; TTM_UPDATETIPTEXT
}

I think I also spotted a bug in TT.ahk:
static TOOLINFO="cbSize,uFlags,hwnd,UPTR uId,RECT rect,UPTR hinst,LPTSTR lpszText,UPTR lParam,void *lpReserved"
should be
static TOOLINFO="cbSize,uFlags,UPTR hwnd,UPTR uId,RECT rect,UPTR hinst,LPTSTR lpszText,UPTR lParam,void *lpReserved"
(found this line 2 times)

HWND_TOPMOST=0xffffffff
might also be invalid on x64 systems? Most likely not, but I don't know.

You need to set the return value to "UPTR" in this line:
T.HWND := DllCall("CreateWindowEx", "UInt", (ClickTrough?0x20:0)|0x8, "str", "tooltips_class32", "UPTR", 0
         , "UInt",0x80000000|(Style?0x100:0)|(NOFADE?0x20:0)|(NoAlimate?0x10:0)|NOPREFIX+1?(NOPREFIX?0x2:0x2):0x2|(AlwaysTip?0x1:0)|(ParseLinks?0x1000:0)|(CloseButton?0x80:0)|(Balloon?0x40:0)
         , "int",0x80000000,"int",0x80000000,"int",0x80000000,"int",0x80000000, "UPTR",Parent?Parent:0,"UPTR",0,"UPTR",0,"UPTR",0)
T.HWND := DllCall("CreateWindowEx", "UInt", (ClickTrough?0x20:0)|0x8, "str", "tooltips_class32", "UPTR", 0
         , "UInt",0x80000000|(Style?0x100:0)|(NOFADE?0x20:0)|(NoAlimate?0x10:0)|NOPREFIX+1?(NOPREFIX?0x2:0x2):0x2|(AlwaysTip?0x1:0)|(ParseLinks?0x1000:0)|(CloseButton?0x80:0)|(Balloon?0x40:0)
         , "int",0x80000000,"int",0x80000000,"int",0x80000000,"int",0x80000000, "UPTR",Parent?Parent:0,"UPTR",0,"UPTR",0,"UPTR",0, "UPtr")

I think you might also have to set "UPtr" return value for all SendMessage calls, since LRESULT is defined as LONG_PTR.

It's still not working for me after those fixes though. Please check if there are any errors like those I mentioned elsewhere, I only checked for some common occurrences that might need fixing.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Many thanks fragman, I will check out on weekend and get back ;)

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
I have done some changes and uploaded new TT.ahk (unfortunately I cannot test now).
Can you please try again?
Links might not work, please test as well :)

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
I now saw the first and second tooltip. Clicking the links didn't do anything, clicking the close button closes it but doesn't proceed.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Right, can you try changing
[color=red]TT_OnMessage[/color](wParam,lParam,msg,hwnd){

	static TTN_FIRST:=0xfffffdf8, @:=TT(9223372036854775808) ;Get main object that holds all ToolTips

	Loop 4

		m += *(lParam + [color=red]16[/color] + A_Index-1) << [color=red]16[/color]*(A_Index-1)

	m:=TTN_FIRST-m

	If m not between 1 and 3

		Return

	Loop 4

		p += *(lParam + 0 + A_Index-1) << [color=red]16[/color]*(A_Index-1)

	If (m=3)

		Loop 4

			option += *(lParam + [color=red]32[/color] + A_Index-1) << [color=red]16[/color]*(A_Index-1)


fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Same result :(

segalion
  • Guests
  • Last active:
  • Joined: --
Thanks a lot...

Can be icon a gif or png file?

segalion
  • Guests
  • Last active:
  • Joined: --

Thanks a lot...

Can be icon a gif or png file?


Seems to work with square png, but it strentch to 16x16

With not "not-square" 40KB gif crash

Do you know if can be possible to paint the original size file image ? That s mean a photo user (not a 16x16).

Thanks in advance

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Any progress? Do you happen to know how to modify the old ToolTip function to get TrayTips working? There's something wrong with the RemoteBuf usage, but I couldn't work it out.

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
@segalion - The function is build the way that associated icon for a file is shown unless it is ico, exe, dll...
You can show any picture, but you need to load it and pass hBitmap.
It is also possible to load a big picture by using margin and loading a picture same way as you do on a Gui (ahk c++ code).

@fragman - I do not have a 64-bit pc now to test, anyway that is what I have so far, can you try that TT.ahk.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
The struct code you pasted there is still crashing. Using the struct code you pasted earlier it works like before, the tooltips show but it's not receiving the close message (or not properly interpreting it).

Btw, for testing x64 you could download a Win7 image from MS, I think they host one somewhere, and run it in a virtual machine. That is, if 60 days are enough ;)

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks for patience, Struct() now fully supports 64-bit (thanks Lexikos).
Also TT() should be working fine now.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
Very nice! I will try it as soon as possible.

segalion
  • Members
  • 50 posts
  • Last active: Oct 16 2014 09:20 AM
  • Joined: 02 Feb 2011

@segalion - The function is build the way that associated icon for a file is shown unless it is ico, exe, dll...
You can show any picture, but you need to load it and pass hBitmap.
It is also possible to load a big picture by using margin and loading a picture same way as you do on a Gui (ahk c++ code).


Hello HotKeyIt, Sorry but I dont understand how I could load the picture and get the hBitmap, put margin options and then use TT with it. Please could you make an example?. Can it be possible only with TT lib and ahk code?

I´ve read this post...
<!-- m -->http://www.autohotke...pic.php?t=67245<!-- m -->
and seem that there are code inside to make the resize
...
DllCall( "gdiplus\GdipCreateBitmapFromStream", UInt,pStream, UIntP,pBitmap )
  DllCall( NumGet(NumGet(1*pStream)+8 ), UInt,pStream )
;make a new bitmap and size it up
  pBitmapResized := Gdip_CreateBitmap(wsize, hsize)
  G := Gdip_GraphicsFromImage(pBitmapResized)
  Gdip_SetInterpolationMode(G, 7)
;fill our new bitmap with a solid color
  pBrush := Gdip_BrushCreateSolid(backgound)
  Gdip_FillRectangle(G, pBrush, 0, 0, wsize, hsize)
;scale the bitmap
  width :=  Gdip_GetImageWidth(pBitmap)
  height := Gdip_GetImageHeight(pBitmap)
  hratio := Floor(wsize *(height/width))
  wratio := Floor(hsize*(width/height))

  if (width>height)
  {
    newHeight:=hratio
    newWidth:=wsize
  }
  else
  if (width<height)
  {
    newWidth:=wratio
    newHeight:=hsize
  }
  else
  if (width=height)
  {
    newWidth:=wsize
    newHeight:=hsize
  }
;spit out a resized bitmap on top of that new bitmap
  Gdip_DrawImage(G, pBitmap, 0, 0,newWidth,newHeight)
  hBitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmapResized)
...

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.