change the background color of a dialog box mfc

前端 未结 3 1097
长情又很酷
长情又很酷 2021-01-15 03:18

I\'m trying to change the background color of a dialog box (win 7, vs2010,c++). I tried to catch WM_CTLCOLOR ,WM_ERASEBKGND and change the color. I manged to change in this

3条回答
  •  情话喂你
    2021-01-15 03:30

    The better way will be to override WM_CTLCOLOR, background of controls such as STATIC will be fill with your color too.

    BEGIN_MESSAGE_MAP(YourDlg, CDialogEx)
        ON_WM_CTLCOLOR()
    END_MESSAGE_MAP()
    ...
    HBRUSH YourDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
        return (HBRUSH)GetStockObject(WHITE_BRUSH);
    }
    

提交回复
热议问题