ToolTipEx - custom fonts and colors in ToolTips
Re: ToolTipEx - custom fonts and colors in ToolTips
As I said, it's a replacement for the built-in ToolTip command.
Re: ToolTipEx - custom fonts and colors in ToolTips
Yes you're right my apologies...just me wrote:As I said, it's a replacement for the built-in ToolTip command.
Re: ToolTipEx - custom fonts and colors in ToolTips
Take a look at this script: http://www.autohotkey.com/board/topic/5 ... ip-window/zcooler wrote:Hi just me!
This is very cool
I have a shell extension installed which displays dynamic data for certain media file types (.TS) on the tooltip in windows explorer. It would be awesome to be abled to make those quite boring looking tooltips nicer (which seems easy to do with this function). It would also be cool to exchange tooltip property labels, which in some cases doesn't describe the dynamic data that well.
My tooltip looks like this translated from Swedish:I would like to exchange:Objecttype: TS-file
Size: 1,50 GB
Length: 01:07.57
Texting: S19E10 - “Castle Hill”
Stationname: Discovery Channel
Objecttype: --> Container format:
Length: --> Duration:
Texting: --> Episode:
Stationname: --> Channel:
Is that possible with this function and if so how?
Regards
zcooler
If you wrote a script to hook every time a tooltip is created, hide it, and then used the above script to get the text and tooltipex to then display it you could essentially have a script that replaces windows tooltips with custom ones...any takers??
Re: ToolTipEx - custom fonts and colors in ToolTips
Oh, it is just a small plugin for displaying extended fileinfo/properties for tv recordings in the explorer. The plugin uses the MediaInfo API for retrieving the extra information. It is very useful when making scripts for the pvr software im using.Skrell wrote:Just curious which shell extension is it ?
Very nice idea, Skrell I will definitely look into this as soon as having more free time.Skrell wrote:Take a look at this script: http://www.autohotkey.com/board/topic/5 ... ip-window/
If you wrote a script to hook every time a tooltip is created, hide it, and then used the above script to get the text and tooltipex to then display it you could essentially have a script that replaces windows tooltips with custom ones...any takers??
zcooler
Re: ToolTipEx - custom fonts and colors in ToolTips
Nice function. However, there's not much reason to limit yourself to the ToolTip API. Using a normal GUI would give a lot more flexibility. You could, for instance, display images, buttons or other controls. Just as a proof of concept, I've adapted just me's function to use GUI commands:
I didn't bother to implement images, or do much testing, since I got bored.
Code: Select all
; ======================================================================================================================
; ToolTipG() Display ToolTips with custom fonts and colors using a GUI.
; Code based on just me's ToolTipEx.
; Requires format.ahk, which is distributed with AutoHotkey v2-alpha.
; Tested with: AHK 1.1.16.05 (U32/U64)
; Tested on: Win 7 Pro (x64)
; Parameters:
; Text - the text to display in the ToolTip.
; If omitted or empty, the ToolTip will be destroyed.
; X - the X position of the ToolTip.
; Default: "" (mouse cursor)
; Y - the Y position of the ToolTip.
; Default: "" (mouse cursor)
; WhichToolTip - the number of the ToolTip.
; Values: 1 - 20
; Default: 1
; Font - Font options and name separated by a comma.
; Default: none (default GUI font)
; BgColor - the background color of the ToolTip.
; Values: RGB integer value or HTML color name.
; Default: "" (default color)
; TxColor - the text color of the ToolTip.
; Values: RGB integer value or HTML color name.
; Default: "" (default color)
; Image - not implemented.
; Default: "" (no image)
; CoordMode - the coordinate mode for the X and Y parameters, if specified.
; Values: "C" (Client), "S" (Screen), "W" (Window)
; Default: "W" (CoordMode, ToolTip, Window)
; Return values:
; On success: The HWND of the ToolTip window.
; On failure: False (ErrorLevel contains additional informations)
; ======================================================================================================================
ToolTipG(Text:="", X:="", Y:="", WhichToolTip:=1, Font:="", BgColor:="", TxColor:="", Image:="", CoordMode:="W") {
; -------------------------------------------------------------------------------------------------------------------
; Check params
TTTX := Text
TTXP := X
TTYP := Y
TTIX := "ToolTip" (WhichToolTip = "" ? 1 : WhichToolTip)
TTHF := Font = "" ? "" : StrSplit(Font, ",", " `t")
TTBC := BgColor
TTTC := TxColor
TTIC := Image
TTCM := CoordMode = "" ? "W" : SubStr(CoordMode, 1, 1)
If TTXP Is Not Digit
Return False, ErrorLevel := "Invalid parameter X-position!", False
If TTYP Is Not Digit
Return False, ErrorLevel := "Invalid parameter Y-Position!", False
If !InStr("CSW", CoordMode)
Return False, ErrorLevel := "Invalid parameter CoordMode!", False
; -------------------------------------------------------------------------------------------------------------------
; Destroy the ToolTip window, if Text is empty
If (TTTX = "") {
Gui %TTIX%: Destroy
Return True
}
; -------------------------------------------------------------------------------------------------------------------
; Save thread settings.
DHW := A_DetectHiddenWindows
DetectHiddenWindows On
LFW := WinExist()
; -------------------------------------------------------------------------------------------------------------------
; Get the virtual desktop rectangle
SysGet, X, 76
SysGet, Y, 77
SysGet, W, 78
SysGet, H, 79
DTW := {L: X, T: Y, R: X + W, B: Y + H}
; -------------------------------------------------------------------------------------------------------------------
; Initialise the ToolTip coordinates. If either X or Y is empty, use the cursor position for the present.
PT := {X: 0, Y: 0}
If (TTXP = "") || (TTYP = "") {
VarSetCapacity(Cursor, 8, 0)
DllCall("User32.dll\GetCursorPos", "Ptr", &Cursor)
Cursor := {X: NumGet(Cursor, 0, "Int"), Y: NumGet(Cursor, 4, "Int")}
PT := {X: Cursor.X + 16, Y: Cursor.Y + 16}
}
; -------------------------------------------------------------------------------------------------------------------
; If either X or Y is specified, get the position of the active window considering CoordMode.
Origin := {X: 0, Y: 0}
If ((TTXP <> "") || (TTYP <> "")) && ((TTCM = "W") || (TTCM = "C")) { ; if (*aX || *aY) // Need the offsets.
HWND := DllCall("User32.dll\GetForegroundWindow", "UPtr")
If (TTCM = "W") {
WinGetPos, X, Y, , , ahk_id %HWND%
Origin := {X: X, Y: Y}
}
Else {
VarSetCapacity(OriginPT, 8, 0)
DllCall("User32.dll\ClientToScreen", "Ptr", HWND, "Ptr", &OriginPT)
Origin := {X: NumGet(OriginPT, 0, "Int"), Y: NumGet(OriginPT, 0, "Int")}
}
}
; -------------------------------------------------------------------------------------------------------------------
; If either X or Y is specified, use the window related position for this parameter.
If (TTXP <> "")
PT.X := TTXP + Origin.X
If (TTYP <> "")
PT.Y := TTYP + Origin.Y
; -------------------------------------------------------------------------------------------------------------------
; If the ToolTip window doesn't exist, create it.
Gui %TTIX%: +LastFoundExist
If !TTHW := WinExist() {
Gui %TTIX%: +AlwaysOnTop +HwndTTHW +ToolWindow -Caption -DPIScale
}
; -------------------------------------------------------------------------------------------------------------------
; Update the text and the font and colors, if specified.
If (TTBC = "")
TTBC := format("{1:08x}", DllCall("GetSysColor", "int", 24))
if (TTTC = "")
TTTC := format("{1:08x}", DllCall("GetSysColor", "int", 23))
Gui %TTIX%: Color, %TTTC% ; border
If (TTIC <> "") {
; TODO: Add image
}
If (TTHF) ; font
Gui %TTIX%: Font, % TTHF[1], % TTHF[2]
; -------------------------------------------------------------------------------------------------------------------
; (Re)create a sub-GUI to simplify text control sizing.
Gui %TTIX%T: Destroy
if TTHF
Gui %TTIX%T: Font, % TTHF[1], % TTHF[2]
Gui %TTIX%T: +Parent%TTIX% +HwndTTHWT -Caption
Gui %TTIX%T: Margin, 3, 2
Gui %TTIX%T: Color, %TTBC%
Gui %TTIX%T: Add, Text, c%TTTC%, %TTTX%
Gui %TTIX%T: Show, NA x1 y1
; -------------------------------------------------------------------------------------------------------------------
; Get the ToolTip window dimensions.
VarSetCapacity(RC, 16, 0)
DllCall("User32.dll\GetWindowRect", "Ptr", TTHWT, "Ptr", &RC)
TTRC := {L: NumGet(RC, 0, "Int"), T: NumGet(RC, 4, "Int"), R: NumGet(RC, 8, "Int"), B: NumGet(RC, 12, "Int")}
TTW := TTRC.R - TTRC.L + 2
TTH := TTRC.B - TTRC.T + 2
; -------------------------------------------------------------------------------------------------------------------
; Check if the Tooltip will be partially outside the virtual desktop and adjust the position, if necessary.
If (PT.X + TTW >= DTW.R)
PT.X := DTW.R - TTW - 1
If (PT.Y + TTH >= DTW.B)
PT.Y := DTW.B - TTH - 1
; -------------------------------------------------------------------------------------------------------------------
; Check if the cursor is inside the ToolTip window and adjust the position, if necessary.
If (TTXP = "") || (TTYP = "") {
TTRC.L := PT.X, TTRC.T := PT.Y, TTRC.R := TTRC.L + TTW, TTRC.B := TTRC.T + TTH
If (Cursor.X >= TTRC.L) && (Cursor.X <= TTRC.R) && (Cursor.Y >= TTRC.T) && (Cursor.Y <= TTRC.B)
PT.X := Cursor.X - TTW - 3, PT.Y := Cursor.Y - TTH - 3
}
; -------------------------------------------------------------------------------------------------------------------
; Show the Tooltip using the final coordinates.
Gui %TTIX%: Show, % "NA x" PT.X " y" PT.Y " w" TTW " h" TTH
; -------------------------------------------------------------------------------------------------------------------
; Restore thread settings.
WinExist("ahk_id " LFW)
DetectHiddenWindows %DHW%
Return TTHW
}
Re: ToolTipEx - custom fonts and colors in ToolTips
Rather than re-inventing the ToolTip command, one can affect its behaviour:
ToolTipFont / ToolTipColor - options for the ToolTip command
ToolTipFont / ToolTipColor - options for the ToolTip command
Re: ToolTipEx - custom fonts and colors in ToolTips
I wasn't interested in re-inventing the command, I just wanted to show how easy the options could be added.lexikos wrote:Rather than re-inventing the ToolTip command, one can affect its behaviour ...
Re: ToolTipEx - custom fonts and colors in ToolTips
You weren't interested, but you did it anyway. I showed an even easier way to add options, without reinventing the command.
Adding options to an existing command is easy. Doing it without making the usage hard to remember is less easy.
Adding options to an existing command is easy. Doing it without making the usage hard to remember is less easy.
Re: ToolTipEx - custom fonts and colors in ToolTips
Just two thoughts:
- IMHO, everyone interested in customizing the ToolTips would willingly loop up the manual, if necessary.
- IMHO, calling a hook for every message sent to the thread causes an inadequate overhead for such a kind of task.
Re: ToolTipEx - custom fonts and colors in ToolTips
1. I'd still prefer to keep the usage simple, but I don't really care, which is another reason why I won't implement it.
2. As I said in the other thread, one could subclass the tooltip window class. Then the overhead would only be for messages sent to tooltips owned by the script, which is negligible. I just took the easiest (laziest) route. Although more than necessary, the overhead is generally irrelevant in most scripts.
2. As I said in the other thread, one could subclass the tooltip window class. Then the overhead would only be for messages sent to tooltips owned by the script, which is negligible. I just took the easiest (laziest) route. Although more than necessary, the overhead is generally irrelevant in most scripts.
Re: ToolTipEx - custom fonts and colors in ToolTips
How?lexikos wrote:As I said in the other thread, one could subclass the tooltip window class.
Edit: Got it!
Re: ToolTipEx - custom fonts and colors in ToolTips
How?just me wrote:How?lexikos wrote:As I said in the other thread, one could subclass the tooltip window class.
Edit: Got it!
Re: ToolTipEx - custom fonts and colors in ToolTips
You can use the same technique that I used to create glass frames around menus.
Re: ToolTipEx - custom fonts and colors in ToolTips
Code: Select all
_TTSubClass() {
Static OrgWndProc := 0
If !(OrgWndProc) {
WindowProc := RegisterCallback("_TTWindowProc", "F")
HTT := DllCall("User32.dll\CreateWindowEx", "UInt", 8, "Str", "tooltips_class32", "Ptr", 0, "UInt", 3
, "Int", 0, "Int", 0, "Int", 0, "Int", 0, "Ptr", A_ScriptHwnd, "Ptr", 0, "Ptr", 0, "Ptr", 0)
If (A_PtrSize = 8)
OrgWndProc := DllCall("User32.dll\SetClassLongPtr", "Ptr", HTT, "Int", -24, "Ptr", WindowProc, "UPtr")
Else
OrgWndProc := DllCall("User32.dll\SetClassLongW", "Ptr", HTT, "Int", -24, "Int", WindowProc, "UInt")
DllCall("User32.dll\DestroyWindow", "Ptr", HTT)
}
Return OrgWndProc
}
_TTWindowProc(hWnd, uMsg, wParam, lParam) {
Static OrgWndProc := 0
Critical
If !(OrgWndProc)
OrgWndProc := _TTSubClass()
If (uMsg = 1036) || (uMsg = 1081) {
ToolTipMargins(,,,, hWnd)
ToolTipTitle(,, hWnd)
ToolTipColor(,, hWnd)
ToolTipFont(,, hWnd)
}
Return DllCall(OrgWndProc, "Ptr", hWnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam, "UInt")
}
Re: ToolTipEx - custom fonts and colors in ToolTips
So like a "window" in a window. O__o window-ception!
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: ToolTipEx - custom fonts and colors in ToolTips
Does this mean you're changing your code to subclass the tooltip window class?just me wrote:Interestingly, I had to call SetClassLongW explicitely to make it work with ANSI on Win 8.1 (x64).Code: Select all
_TTSubClass() { Static OrgWndProc := 0 If !(OrgWndProc) { WindowProc := RegisterCallback("_TTWindowProc", "F") HTT := DllCall("User32.dll\CreateWindowEx", "UInt", 8, "Str", "tooltips_class32", "Ptr", 0, "UInt", 3 , "Int", 0, "Int", 0, "Int", 0, "Int", 0, "Ptr", A_ScriptHwnd, "Ptr", 0, "Ptr", 0, "Ptr", 0) If (A_PtrSize = 8) OrgWndProc := DllCall("User32.dll\SetClassLongPtr", "Ptr", HTT, "Int", -24, "Ptr", WindowProc, "UPtr") Else OrgWndProc := DllCall("User32.dll\SetClassLongW", "Ptr", HTT, "Int", -24, "Int", WindowProc, "UInt") DllCall("User32.dll\DestroyWindow", "Ptr", HTT) } Return OrgWndProc } _TTWindowProc(hWnd, uMsg, wParam, lParam) { Static OrgWndProc := 0 Critical If !(OrgWndProc) OrgWndProc := _TTSubClass() If (uMsg = 1036) || (uMsg = 1081) { ToolTipMargins(,,,, hWnd) ToolTipTitle(,, hWnd) ToolTipColor(,, hWnd) ToolTipFont(,, hWnd) } Return DllCall(OrgWndProc, "Ptr", hWnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam, "UInt") }
Re: ToolTipEx - custom fonts and colors in ToolTips
No. This function doesn't need to subclass anything.
Re: ToolTipEx - custom fonts and colors in ToolTips
Hey just me,just me wrote:Joedf, ToolTips only support icons (within the title, but the title text won't be drawn using the specified font's size), 16 * 16 on Win XP and also 32 * 32 on Vista+. Do you want them?
I did some testing with TooltipEx() and AddTooltip() and this limitation is a total buzzkill. Although if using system icons they utilize the empty space under the title icon better (see AddTooltip() sample) and not just the row height of the title if applying a custom icon like in the ToolTipEx sample (see full size custom icon to the left of the ToolTipEx sample). It would surely be very intresting to know (I will have to ask) how the DVBViewer guys did it when adding the icons to their menu tooltips (see the samples to the left in image). Very cool when the icon arrow changes direction depending on which side (above or below) the tooltip is displayed of the RadioCheckButton.
Re: ToolTipEx - custom fonts and colors in ToolTips
Hi zcooler,
I'm pretty sure they are drawing the tooltip themselves in case they actually use a common tooltip control.
I'm pretty sure they are drawing the tooltip themselves in case they actually use a common tooltip control.
And very unnecessary, because the hilite color clearly indicates the menu item.Very cool when the icon arrow changes direction depending on which side (above or below) the tooltip is displayed of the RadioCheckButton.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 69 guests