如何将 CDialog的背景画成某一种颜色?(写出代码) 怎么CDialog 没有setbkcolor之类的函数啊?想用CBrush又不知道,CBrush 怎么设置颜色。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 映射WM_CTLCOLORHBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here hbr = ::CreateSolidBrush(RGB(255,255,0));//这里可以写你要的颜色! // TODO: Return a different brush if the default is not desired return hbr;} 除此之外,还有什么其他方法吗?? 因为使用了换肤的DLL后,这功能好像就无效了。 能放一个控件 上去专门绘图吗?? 用什么控件比较好?? 那就映射WM_PAINTvoid CAboutDlg::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CBrush brush; brush.CreateSolidBrush(RGB(255,0,0));//颜色! CRect rct; GetClientRect(&rct); dc.FillRect(&rct,&brush); // Do not call CDialog::OnPaint() for painting messages} handwolf(初学者)的方法暗藏杀机,会造成GDI资源的泄漏!!brush.CreateSolidBrush(RGB(255,0,0));//就是这句要把画刷定义成员变量。 直接在CXXXApp::InitInstance函数中加入SetDialogBkColor(RGB(204, 163, 220),RGB(46, 21, 55) ); 就可以了。 to bigelm(枯燥着快乐着): 把泄露的原因说给我听听。 CXXXApp::InitInstance函数中加入SetDialogBkColor();在Dlg.cpp里面响应 映射WM_CTLCOLORHBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); hbr = ::CreateSolidBrush(RGB(255,255,0));//这里可以写你要的颜色! return hbr;} 这段时间正在做一个产品的终端界面显示,我在界面中也做过,把我实现的代码拷给你看看: 定义画刷: CBrush m_beijingbrush1; CBrush m_beijingbrush; 首先,在对话框OnInitDialog()函数中初始化画刷: m_beijingbrush.CreateSolidBrush(RGB(142, 193, 232)); // bq-9生成主对话框背景一绿色刷子 m_beijingbrush1.CreateSolidBrush(RGB(142, 193, 232)); // bq-9生成透过主对话框背景的一绿色刷子 其次,为对话框类加一个OnCtlColor()函数(在类的Add windows message handler中添加这个函数),我的代码是:HBRUSH CZhbusDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 在这个函数中添加代码,我的代码是: if (nCtlColor ==CTLCOLOR_DLG) return m_beijingbrush; //返加绿色刷子 if (nCtlColor==CTLCOLOR_STATIC) { pDC->SetTextColor(RGB(48,24,141));//设置静态static的文字颜色// pDC->SetBkColor(RGB(137, 181, 184)); //设置静态static的文字背景颜色yuan bq pDC->SetBkColor(RGB(142, 193, 232)); //bq-9 } if (nCtlColor==CTLCOLOR_EDIT) { pDC->SetTextColor(RGB(141,32,145));//设置edit框的文字颜色// pDC->SetBkColor(RGB(132, 69, 165)); //设置edit框的文字背景颜色bq-1 pDC->SetBkColor(RGB(142, 193, 232)); //bq-9 } return m_beijingbrush1; 就3个地方,自己理解啊!! 双cpu 多线程 今天看了一个介绍连接点的文章,和我从网上下载的很不相同,请各位高给点评一下! vc中用Ado怎么实现批量插入的操作? 关于WaitForSingleObject和CPU占用时间的问题,欢迎讨论。 太简单的问题 1000分,求高质量的界面控制源代码,内详! 如何重载子窗的最大化功能??? STATIC控件中绘制图形的问题 I am waiting 如何,各根据bmp文件径,生成 HBITMAP位图??? 请问如何改变对话框的背景风格? 请教一个有关串口通信中如何命令数据重发的问题
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
hbr = ::CreateSolidBrush(RGB(255,255,0));//这里可以写你要的颜色!
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CAboutDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CBrush brush;
brush.CreateSolidBrush(RGB(255,0,0));//颜色!
CRect rct;
GetClientRect(&rct);
dc.FillRect(&rct,&brush); // Do not call CDialog::OnPaint() for painting messages
}
brush.CreateSolidBrush(RGB(255,0,0));//就是这句
要把画刷定义成员变量。
CXXXApp::InitInstance函数中加入
SetDialogBkColor(RGB(204, 163, 220),RGB(46, 21, 55) );
就可以了。
把泄露的原因说给我听听。
SetDialogBkColor();在Dlg.cpp里面响应
映射WM_CTLCOLOR
HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
hbr = ::CreateSolidBrush(RGB(255,255,0));//这里可以写你要的颜色! return hbr;
}
定义画刷:
CBrush m_beijingbrush1;
CBrush m_beijingbrush;
首先,在对话框OnInitDialog()函数中初始化画刷:
m_beijingbrush.CreateSolidBrush(RGB(142, 193, 232)); // bq-9生成主对话框背景一绿色刷子
m_beijingbrush1.CreateSolidBrush(RGB(142, 193, 232)); // bq-9生成透过主对话框背景的一绿色刷子
其次,为对话框类加一个OnCtlColor()函数(在类的Add windows message handler中添加这个函数),我的代码是:
HBRUSH CZhbusDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 在这个函数中添加代码,我的代码是:
if (nCtlColor ==CTLCOLOR_DLG)
return m_beijingbrush; //返加绿色刷子 if (nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetTextColor(RGB(48,24,141));//设置静态static的文字颜色// pDC->SetBkColor(RGB(137, 181, 184)); //设置静态static的文字背景颜色yuan bq pDC->SetBkColor(RGB(142, 193, 232)); //bq-9
}
if (nCtlColor==CTLCOLOR_EDIT)
{
pDC->SetTextColor(RGB(141,32,145));//设置edit框的文字颜色// pDC->SetBkColor(RGB(132, 69, 165)); //设置edit框的文字背景颜色bq-1
pDC->SetBkColor(RGB(142, 193, 232)); //bq-9
}
return m_beijingbrush1; 就3个地方,自己理解啊!!