Can anyone tell me what's up?
Simple Gui
Code: Select all
Gui, add, Text,, Some stuff here
Gui, add, Checkbox, vCB1 hwndH1, Checkbox one label
Gui, add, Checkbox, vCB2 hwndH2, Checkbox two label
Gui, Add, Button, gBtn, Button
Gui, Show
Return
Btn:
Gui, Submit, NoHide
SetStaticColor(H1, "0x60FF60")
GuiControl, Disabled, CB1
SetStaticColor(H2, "0x60FF60")
GuiControl, Disabled, CB2
Return
GuiEscape:
GuiClose:
ExitApp
Gui with tabs added
Code: Select all
Gui, Add, Tab3,, One|Two
Gui, Tab, 1
Gui, add, Text,, Some stuff here
Gui, Tab, 2
Gui, add, Checkbox, vCB1 hwndH1, Checkbox label
Gui, add, Checkbox, vCB2 hwndH2, Checkbox label
Gui, Add, Button, gBtn, Button
Gui, Show
Return
Btn:
Gui, Submit, NoHide
SetStaticColor(H1, "0x60FF60")
GuiControl, Disabled, CB1
SetStaticColor(H2, "0x60FF60")
GuiControl, Disabled, CB2
Return
GuiEscape:
GuiClose:
ExitApp
Functions common to both - courtesy of @teadrinker viewtopic.php?p=179339#p179339
Code: Select all
SetStaticColor(hStatic, b_color, f_color := 0){
static arr := [], GWL_WNDPROC := -4
b_color := DllCall("Ws2_32\ntohl", UInt, b_color << 8, UInt)
f_color := DllCall("Ws2_32\ntohl", UInt, f_color << 8, UInt)
hGui := DllCall("GetParent", Ptr, hStatic, Ptr)
If !arr.HasKey(hGui) {
arr[hGui] := {}, arr[hGui].Statics := []
arr[hGui].ProcOld := DllCall("SetWindowLong" . (A_PtrSize = 8 ? "Ptr" : ""), Ptr, hGui, Int, GWL_WNDPROC
, Ptr, RegisterCallback("WindowProc", "", 4, Object(arr[hGui])), Ptr)
}Else If arr[hGui].Statics.HasKey(hStatic)
DllCall("DeleteObject", Ptr, arr[hGui].Statics[hStatic].hBrush)
arr[hGui].Statics[hStatic] := { b_color: b_color, f_color: f_color
, hBrush: DllCall("CreateSolidBrush", UInt, b_color, Ptr) }
WinSet, Redraw,, ahk_id %hStatic%
}
WindowProc(hwnd, uMsg, wParam, lParam){
Critical
static WM_CTLCOLORSTATIC := 0x138
obj := Object(A_EventInfo)
If (uMsg = WM_CTLCOLORSTATIC && k := obj.Statics[lParam]){
DllCall("SetBkColor", Ptr, wParam, UInt, k.b_color)
DllCall("SetTextColor", Ptr, wParam, UInt, k.f_color)
Return k.hBrush
}
Return DllCall("CallWindowProc", Ptr, obj.ProcOld, Ptr, hwnd, UInt, uMsg, Ptr, wParam, Ptr, lParam)
}