Anyhow, pretty much everything is working, however, I'd like, if possible, to be able to set the border colour, or simply remove borders. At present, it appears that whatever you set the text colour to, the border uses that colour.
E.g. in ToolTipEx_sample.ahk, the text/border colours were the same in both example ToolTips:
ToolTipEx - custom fonts and colors in ToolTips - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=4350
Any general comments on the script, or on creating ToolTips, are welcome.
Code: Select all
;GUIs via DllCall: ToolTips
#Persistent
#SingleInstance force
DetectHiddenWindows, On
vSizeTI := A_PtrSize=8?72:48
;vText := " hello world `r`nhello world`r`nhello world"
vText := "hello world`r`nhello world`r`nhello world"
vText2 := vText
;vText2 := SubStr(vText, 2)
VarSetCapacity(TOOLINFO, vSizeTI, 0)
NumPut(vSizeTI, &TOOLINFO, 0, "UInt") ;cbSize
NumPut(0x20, &TOOLINFO, 4, "UInt") ;uFlags ;TTF_TRACK := 0x20
NumPut(&vText, &TOOLINFO, A_PtrSize=8?48:36, "Ptr") ;lpszText
;create window
;TTS_NOPREFIX := 0x2 ;TTS_ALWAYSTIP := 0x1
;WS_EX_TOPMOST := 0x8
hTT := DllCall("user32\CreateWindowEx", UInt,0x8, Str,"tooltips_class32", Ptr,0, UInt,0x3, Int,0, Int,0, Int,0, Int,0, Ptr,A_ScriptHwnd, Ptr,0, Ptr,0, Ptr,0)
;set text/background colours, and distance between text/margins
;vColBk := 0x00FFFF ;BGR
;vColTx := 0xFF0000 ;BGR
vColBk := 0xF0F0F0 ;BGR
vColTx := 0x000000 ;BGR
DllCall("uxtheme\SetWindowTheme", Ptr,hTT, Ptr,0, Str,"")
VarSetCapacity(RECT, 16, 0)
;vRect := "4,4,4,1"
;vRect := "20,20,20,20"
vRect := "8,4,180,1"
Loop, Parse, vRect, % ","
NumPut(A_LoopField, &RECT, A_Index*4-4, "Int")
SendMessage, 0x41A, 0, % &RECT,, % "ahk_id " hTT ;TTM_SETMARGIN := 0x41A
SendMessage, 0x413, % vColBk, 0,, % "ahk_id " hTT ;TTM_SETTIPBKCOLOR := 0x413
SendMessage, 0x414, % vColTx, 0,, % "ahk_id " hTT ;TTM_SETTIPTEXTCOLOR := 0x414
;to allow multiline ToolTips
SendMessage, 0x418, 0, 200,, % "ahk_id " hTT ;TTM_SETMAXTIPWIDTH := 0x418
;set font
vFontName := "MS Shell Dlg", vFontSize := 18
vFontWeight := 400, vFontHeight := -Round(vFontSize*A_ScreenDPI/72)
hFont := DllCall("gdi32\CreateFont", Int,vFontHeight, Int,0, Int,0, Int,0, Int,vFontWeight, UInt,0, UInt,0 ,UInt,0, UInt,0, UInt,0, UInt,0, UInt,0, UInt,0, Str,vFontName, Ptr)
SendMessage, 0x30, % hFont, 0,, % "ahk_id " hTT ;WM_SETFONT := 0x30
SendMessage, % A_IsUnicode?0x432:0x404, 0, % &TOOLINFO,, % "ahk_id " hTT ;TTM_ADDTOOLW := 0x432
vWinX := 300, vWinY := 300
SendMessage, 0x412, 0, % (vWinX&0xFFFF)|(vWinY<<16),, % "ahk_id " hTT ;TTM_TRACKPOSITION := 0x412
SendMessage, 0x411, 1, % &TOOLINFO,, % "ahk_id " hTT ;TTM_TRACKACTIVATE := 0x411
;didn't work to set border style
;WinSet, Style, +0x40000, % "ahk_id " hTT
;WinSet, Style, +0x400000, % "ahk_id " hTT
;WinSet, Style, +0x800000, % "ahk_id " hTT
;unknown ExStyle
;WinSet, ExStyle, -0x80000, % "ahk_id " hTT
;didn't work to resize ToolTip
;WinMove, % "ahk_id " hTT,, 300, 300, 302, 41
Progress, zh0 b1 c0 fs18 x300 y440, % vText2
Sleep, 5000
DllCall("DestroyWindow", Ptr,hTT)
Progress, Off
return