901223-如何更改对话框的背景色? [英] 901223 - how to change background color of a dialog?
本文介绍了901223-如何更改对话框的背景色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
BOOL CMyDialog :: PreCreateWindow(CREATESTRUCT& cs)
{
// TODO:在此处添加您的专用代码和/或调用基类
如果(CDialog :: PreCreateWindow(cs)==否)
返回为假;
CBrush br;
VERIFY(br.CreateSolidBrush(RGB( 251 , 235 , 202 ))));
cs.lpszClass = AfxRegisterWndClass( 0 ,:: LoadCursor(NULL,IDC_ARROW),br,NULL);
返回 TRUE;
}
,但看来DoModal不会导致它被调用.
您的建议是什么?
解决方案
用勺子喂答案.
CngfhnDlg :: CngfhnDlg(CWnd * pParent /* = NULL */ ) :CDialog(CngfhnDlg :: IDD,pParent) { m_hIcon = AfxGetApp()-> LoadIcon(IDR_MAINFRAME); m_brush.CreateSolidBrush(RGB( 0 , 255 , 0 )); } HBRUSH CngfhnDlg :: OnCtlColor(CDC * pDC,CWnd * pWnd,UINT nCtlColor) { HBRUSH hbr = CDialog :: OnCtlColor(pDC,pWnd,nCtlColor); // 将句柄返回到我们的CBrush对象 hbr = m_brush; 返回 hbr; }
(除了说它永远看起来都不好,而且可能与Microsoft的UX准则背道而驰)
看看 CWnd :: OnCtlColor [ ^ ].
带有渐变背景和颜色更改进度栏 [ ^ ]是有用的文章.
hi
for changing the default background color of a dialog, i tried overriding it PreCreateWindow function:
BOOL CMyDialog::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
if (CDialog::PreCreateWindow(cs) == FALSE)
return FALSE;
CBrush br;
VERIFY(br.CreateSolidBrush(RGB(251, 235, 202)));
cs.lpszClass = AfxRegisterWndClass(0, ::LoadCursor(NULL, IDC_ARROW), br, NULL);
return TRUE;
}
but it seems that DoModal doesn''t cause it to be called.
what''s ur suggestion?
解决方案
spoon feeding the answer.
CngfhnDlg::CngfhnDlg(CWnd* pParent /*=NULL*/) : CDialog(CngfhnDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_brush.CreateSolidBrush(RGB(0, 255, 0)); } HBRUSH CngfhnDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // Return handle to our CBrush object hbr = m_brush; return hbr; }
(other than saying that it will never look good and is probably contrary to Microsoft''s UX guideline )
Have a look at CWnd::OnCtlColor[^].
Dialog Box with gradient background and Color changing progress bar[^] is a useful article.
这篇关于901223-如何更改对话框的背景色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文