VS2010: checkboxes have a gray background on a white tab in the dialog box. How to fix it?

I am adding a new dialog to a C ++ application (Visual Studio 2010). I can not get rid of the gray background of the flags, which are by default marked on the tab:

Dialog being edited in the resource editor

The related text in the .rc file is as follows:

IDD_ExportHTML DIALOGEX 164, 128, 292, 136
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
    LTEXT           "statFileName0",102,9,9,59,8
    LTEXT           "statFileName",101,9,20,190,8
    CONTROL         "",150,"SysTabControl32",TCS_RAGGEDRIGHT,11,38,201,92
    DEFPUSHBUTTON   "btnOK",IDOK,241,97,45,15
    PUSHBUTTON      "btnCancel",IDCANCEL,241,115,45,15
    CONTROL         "chboxLines",106,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,34,71,135,12
    CONTROL         "chboxBackground",107,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,34,84,135,12
    CONTROL         "chboxPaging",108,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,34,98,135,12
END

This behaves the same as when starting the application. What should I set or tell checkboxes that they are children of a tab? Or how can I fix the problem

Thanks for your time and experience, Petr

+5
source share
1 answer

Do something like this:

HBRUSH CYourDialogHere::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{

    HBRUSH hbr = (HBRUSH)m_brush;
    CWnd *pCheckBox = GetDlgItem(IDC_CHECK1);  // put ID of your checkbox here.

    if (*pCheckBox == *pWnd)
    {
        pDC->SetBkColor(RGB(255, 0, 0));
    }
    else
        hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    return hbr;
}

More info here

, ++, .h , OnCtlColor .cpp.

+5

All Articles