OnCtlColor函數怎麼保存CColorDiaog對話框設置的對話框?我不希望它每次都調用。謝謝
void CApp2Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
CColorDialog colorDia;
if (colorDia.DoModal() == IDOK)
{
m_color = colorDia.GetColor();
GetDlgItem(IDC_STATIC_1)->InvalidateRect(NULL);
}
}
HBRUSH CApp2Dlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
m_brush.CreateSolidBrush(m_color);
// TODO: Change any attributes of the DC here
UpdateData(TRUE);
if (pWnd->GetDlgCtrlID() == IDC_STATIC_1)
{
pDC->SetBkColor(m_color);
pDC->SetBkMode(OPAQUE);
return m_brush;
}
UpdateData(FALSE);
// TODO: Return a different brush if the default is not desired
return hbr;
}