I am using szujeq's ControlColor function (an old version as I could not get 1.02 to work for me) to change the background colour of the command links, but it doesn't change the text. And the blue text on the coloured background is hard to read at times.
My guess is that DllCall is required here, but that's not something I am familiar with just yet. Any help would be greatly appreciated.
Code: Select all
content :=
(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Nec ultrices dui sapien eget. Feugiat scelerisque
varius morbi enim nunc faucibus a."
)
Gui +hWndhWndMainWnd -Caption
Gui Color, 0xC0C0C0
Gui Font, s18 w600 q5 cBlack, Verdana
Gui Add, Text, hwndwhndTitle x8 y8 w370 h30 +0x200, Title
Gui Font, s12 Bold
Gui Add, Text, x8 y48 w100 h23 +0x200, Subtitle
Gui Font, s10 Norm
Gui Add, Text, x8 y80 w370 h46, % content
Gui Add, Custom, hWndhwndButton1 gclick x0 y152 w193 h58 ClassButton +0x200E, Option 1`nSelect option 1
ControlColor(hwndButton1, hWndMainWnd, 0xB53535, 0x7F7F7F)
Gui Add, Custom, hWndhwndButton2 gclick x193 y152 w193 h58 ClassButton +0x200E, Option 2`nSelect option 2
ControlColor(hwndButton2, hWndMainWnd, 0x81C94B, 0x7F7F7F)
Gui Show, w386 h210, InfoCOPY
OnMessage(0x201, "WM_LBUTTONDOWN")
Return
GuiEscape(GuiHwnd) {
Gui, Destroy
}
WM_LBUTTONDOWN() {
PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN = 0xA1, HTCAPTION = 2
}
click(CtrlHwnd, GuiEvent, EventInfo, ErrLevel := "") {
Gui, +OwnDialogs
If (GuiEvent != "Normal")
Return
}
; http://www.autohotkey.com/board/topic/104539-controlcol-set-background-and-text-color-gui-controls/
ControlColor(Control, Window, bc := "", tc := "", Redraw := 1) {
a := {}
a["c"] := Control
a["g"] := Window
a["bc"] := (bc = "") ? "" : (((bc & 255) << 16) + (((bc >> 8) & 255) << 8) + (bc >> 16))
a["tc"] := (tc = "") ? "" : (((tc & 255) << 16) + (((tc >> 8) & 255) << 8) + (tc >> 16))
CC_WindowProc("Set", a, "", "")
If (Redraw) {
WinSet Redraw,, ahk_id %Control%
}
}
CC_WindowProc(hWnd, uMsg, wParam, lParam) {
Static Win := {}
If uMsg Between 0x132 And 0x138
If (Win[hWnd].HasKey(lParam)) {
If (tc := Win[hWnd, lParam, "tc"]) {
DllCall("gdi32.dll\SetTextColor", "Ptr", wParam, "UInt", tc)
}
If (bc := Win[hWnd, lParam, "bc"]) {
DllCall("gdi32.dll\SetBkColor", "Ptr", wParam, "UInt", bc)
}
Return Win[hWnd, lParam, "Brush"] ; Return the HBRUSH to notify the OS that we altered the HDC.
}
If (hWnd = "Set") {
a := uMsg
Win[a.g, a.c] := a
If (Win[a.g, a.c, "tc"] == "") And (Win[a.g, a.c, "bc"] == "")
Win[a.g].Remove(a.c, "")
If Not Win[a.g, "WindowProcOld"]
Win[a.g,"WindowProcOld"] := DllCall("SetWindowLong" . (A_PtrSize == 8 ? "Ptr" : "")
, "Ptr", a.g, "Int", -4, "Ptr", RegisterCallback("CC_WindowProc", "", 4), "UPtr")
If Win[a.g, a.c, "Brush"]
DllCall("gdi32.dll\DeleteObject", "Ptr", Brush)
If (Win[a.g, a.c, "bc"] != "")
Win[a.g, a.c, "Brush"] := DllCall("gdi32.dll\CreateSolidBrush", "UInt", a.bc, "UPtr")
Return
}
Return DllCall("CallWindowProc", "Ptr", Win[hWnd, "WindowProcOld"], "Ptr", hWnd, "UInt", uMsg, "Ptr", wParam, "Ptr", lParam, "Ptr")
}