我现在的问题是对话框的背景颜色已经设置成功了,但实际的效果与DreamWare或PS上的颜色有所差别(相同的RGB(207, 222, 245))?
HBRUSH ContrlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkColor(RGB(207, 222, 245)); //编辑文字的背景色
if(nCtlColor == CTLCOLOR_DLG){ //对话框
return m_brush;
}
return m_brush;
}
HBRUSH ContrlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkColor(RGB(207, 222, 245)); //编辑文字的背景色
if(nCtlColor == CTLCOLOR_DLG){ //对话框
return m_brush;
}
return m_brush;
}
{
CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CRect rect;
CPaintDC dc(this);
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(182,248,163)); //设置为绿色背景
CDialog::OnPaint();
CDialog::OnPaint();
}
要不然楼主换一种办法?上述代码写在OnPaint里,颜色与在PS里看到的颜色是一样的
你用vc想实现带透明度的就会有问题。与你ps上效果不一致