You forgot to release the device context inside the function.
While DrawFrameControl() may integrate well in a standard Win9x environment with its classic look, in a themed system it will stand out, and not in a positive way. First solution may be better.
Code: Select all
#NoEnv
Global Chk1 := True
Global Chk2 := True
Global Chk3 := False
Gui Font, s14, Segoe UI
Gui Add, Text, hWndhChk1 vChk1 gCheck x10 y10 w32 h32
Gui Add, Text, x50 y12 w200 h23, Label 1
Gui Add, Text, hWndhChk2 vChk2 gCheck x10 y54 w32 h32
Gui Add, Text, x50 y56 w200 h23, Label 2
Gui, Font, s28 c0xFF0000 w400, Wingdings
Gui, Add, Text, x10 y+10 w32 h32 +0x200 Center +BackgroundTrans hwndhChk3 vChk3 gToggleChk, ű
Gui, Font, s14 cDefault, Segoe UI
Gui Add, Text, x+8 yp w200 hp 0x200 vLChk3 gToggleChk, Label 3
Gui Show, w481 h381, DrawFrameControl Test
DrawCheckBox(hChk1, Chk1)
DrawCheckBox(hChk2, Chk2)
Return
GuiEscape:
GuiClose:
ExitApp
Check:
%A_GuiControl% := !%A_GuiControl%
GuiControlGet hWnd, hWnd, %A_GuiControl%
DrawCheckBox(hWnd, %A_GuiControl%)
Return
DrawCheckBox(hWnd, Checked := True) {
hDC := DllCall("GetDC", "Ptr", hWnd, "Ptr")
VarSetCapacity(RECT, 16, 0)
NumPut(0, RECT, 0, "Int")
NumPut(0, RECT, 4, "Int")
NumPut(32, RECT, 8, "Int")
NumPut(32, RECT, 12, "Int")
DllCall("DrawFrameControl", "Ptr", hDC, "Ptr", &RECT, "UInt", 4, "UInt", Checked ? 0x400 : 0)
DllCall("ReleaseDC", "Ptr", hWnd, "Ptr", hDC)
}
ToggleChk:
ctrl := InStr(A_GuiControl, "L") ? SubStr(A_GuiControl, 2) : A_GuiControl
%ctrl% := !%ctrl%
Gui, Font, % "s28 " (%ctrl% ? "c0x0000FF" : "c0xFF0000") " w400", Wingdings
GuiControl, Font, %ctrl%
GuiControl,, %ctrl%, % (%ctrl% ? "ü" : "ű")
Gui, Font
return