-
Notifications
You must be signed in to change notification settings - Fork 71
/
ToolTipOpt.ahk
81 lines (76 loc) · 2.59 KB
/
ToolTipOpt.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
; ToolTipOpt v1.004
; Changes:
; v1.001 - Pass "Default" to restore a setting to default
; v1.002 - ANSI compatibility
; v1.003 - Added workarounds for ToolTip's parameter being overwritten
; by code within the message hook.
; v1.004 - Fixed text colour.
ToolTipFont(Options := "", Name := "", hwnd := "") {
static hfont := 0
if (hwnd = "")
hfont := Options="Default" ? 0 : _TTG("Font", Options, Name), _TTHook()
else
DllCall("SendMessage", "ptr", hwnd, "uint", 0x30, "ptr", hfont, "ptr", 0)
}
ToolTipColor(Background := "", Text := "", hwnd := "") {
static bc := "", tc := ""
if (hwnd = "") {
if (Background != "")
bc := Background="Default" ? "" : _TTG("Color", Background)
if (Text != "")
tc := Text="Default" ? "" : _TTG("Color", Text)
_TTHook()
}
else {
VarSetCapacity(empty, 2, 0)
DllCall("UxTheme.dll\SetWindowTheme", "ptr", hwnd, "ptr", 0
, "ptr", (bc != "" && tc != "") ? &empty : 0)
if (bc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1043, "ptr", bc, "ptr", 0)
if (tc != "")
DllCall("SendMessage", "ptr", hwnd, "uint", 1044, "ptr", tc, "ptr", 0)
}
}
_TTHook() {
static hook := 0
if !hook
hook := DllCall("SetWindowsHookExW", "int", 4
, "ptr", RegisterCallback("_TTWndProc"), "ptr", 0
, "uint", DllCall("GetCurrentThreadId"), "ptr")
}
_TTWndProc(nCode, _wp, _lp) {
Critical 999
;lParam := NumGet(_lp+0*A_PtrSize)
;wParam := NumGet(_lp+1*A_PtrSize)
uMsg := NumGet(_lp+2*A_PtrSize, "uint")
hwnd := NumGet(_lp+3*A_PtrSize)
if (nCode >= 0 && (uMsg = 1081 || uMsg = 1036)) {
_hack_ = ahk_id %hwnd%
WinGetClass wclass, %_hack_%
if (wclass = "tooltips_class32") {
ToolTipColor(,, hwnd)
ToolTipFont(,, hwnd)
}
}
return DllCall("CallNextHookEx", "ptr", 0, "int", nCode, "ptr", _wp, "ptr", _lp, "ptr")
}
_TTG(Cmd, Arg1, Arg2 := "") {
static htext := 0, hgui := 0
if !htext {
Gui _TTG: Add, Text, +hwndhtext
Gui _TTG: +hwndhgui +0x40000000
}
Gui _TTG: %Cmd%, %Arg1%, %Arg2%
if (Cmd = "Font") {
GuiControl _TTG: Font, %htext%
SendMessage 0x31, 0, 0,, ahk_id %htext%
return ErrorLevel
}
if (Cmd = "Color") {
hdc := DllCall("GetDC", "ptr", htext, "ptr")
SendMessage 0x138, hdc, htext,, ahk_id %hgui%
clr := DllCall("GetBkColor", "ptr", hdc, "uint")
DllCall("ReleaseDC", "ptr", htext, "ptr", hdc)
return clr
}
}