Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checkbox change the text color [duplicate]

The background changed, but the text color not. here my code:

case WM_CTLCOLORSTATIC:
{
    DWORD CtrlID = GetDlgCtrlID((HWND)lParam); //Window Control ID

    if(CtrlID == IDC_CHECK_CHAT)
    {
        HDC hdcStatic = (HDC) wParam;
        SetTextColor(hdcStatic, RGB(255,255,255));
        SetBkColor(hdcStatic, RGB(70,70,70));
        return (INT_PTR)hBrush;
    }
}

resource file:

CONTROL         "Blah Blah Blah",IDC_CHECK_CHAT,
                "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,72,137,10
like image 257
Ido Hadar Avatar asked Oct 18 '25 14:10

Ido Hadar


1 Answers

You need to first remove theme with SetWindowTheme:

HWND hwndCheckbox = GetDlgItem(_hdlg, IDC_CHECK_CHAT);
SetWindowTheme(hwndCheckbox, L"wstr", L"wstr");

before you could color the text.

like image 195
Jichao Avatar answered Oct 20 '25 03:10

Jichao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!