Can I color a Tooltip and Msgbox? Topic is solved
Can I color a Tooltip and Msgbox?
Is it possible to color the background and text. If so, I would like the scripts with the backgrounds to be teal, the hexadecimal color value is #008080, and have text to be green, the hexadecimal color value is #00FF00.
Re: Can I color a Tooltip and Msgbox?
Code: Select all
box("Message", "It worked.", "Red", 8080)
box("Message #2", "It worked again.", "Black", "Red")
box("Message #3", "It worked yet again.")
box(ttitle, ttext, textColor := "Black", bkg := "White") {
Gui, Box:New,, %ttitle%
Gui, Font, s10 c%textColor%
Gui, Color, %bkg%
Gui, Add, Text,, %ttext%
Gui, Add, Button, w250 Default, OK
Gui, Show
WinWaitClose, %ttitle% ahk_class AutoHotkeyGUI
Return
BoxButtonOK:
Gui, Destroy
Return
}
Re: Can I color a Tooltip and Msgbox?
This is awesome, but how can I make this Tooltips?
Re: Can I color a Tooltip and Msgbox?
Searching the forum?
viewtopic.php?t=4350
viewtopic.php?t=4350
Re: Can I color a Tooltip and Msgbox?
The code is confusing me . Please make a simple script.
Re: Can I color a Tooltip and Msgbox?
Simply remove the caption and border from the GUI and you'll have a ToolTip-look-alike.
-
- Posts: 854
- Joined: 21 Dec 2015, 02:34
Re: Can I color a Tooltip and Msgbox? Topic is solved
found this script from Lexikos.
Code: Select all
z::
ToolTipColor("Red", "Yellow")
Tooltip, This Is A Colored Tooltip
sleep, 2000
Tooltip,
Return
; 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
}
}
Re: Can I color a Tooltip and Msgbox?
A simple script, indeed.