16,467
社区成员
发帖
与我相关
我的任务
分享
HBRUSH CWorkDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor == CTLCOLOR_DLG )
{
HBRUSH B = CreateSolidBrush(m_bkColor); //背景色
return B;
}
return hbr;
}
void CWorkDlg::OnButton2() //颜色设置/
{
// TODO: Add your control notification handler code here
CClientDC dc(this) ;
CRect r ;
GetClientRect(&r);//取得对话框客户区大小
CColorDialog dlg ;
if(IDOK == dlg.DoModal())
{
m_bkColor = dlg.GetColor(); //这里设置成员变量m_bkColor 的值
Invalidate();
}
}