C++ BackColor_Dialog

相关主题
1. 用纯色 设置对话对话框的背景色

2. 用位图 设置对话对话框的背景色

3. [使用Picture Ctrl来设置背景图片](使用Picture
Ctrl来设置背景图片)

对话框背景色
其他相关[CColorDialog](CColorDialog)
代码::用纯色 设置对话对话框的背景色


HBRUSHCProject01Dlg::OnCtlColor(CDC*pDC,CWnd*pWnd,UINTnCtlColor){HBRUSHhbr=CDialog::OnCtlColor(pDC,pWnd,nCtlColor);// TODO: Change any attributes of the DC hereCBrushcbrush(RGB(255,0,0));CRectcrect;GetClientRect(crect);pDC->SelectObject(&cbrush);pDC->FillRect(crect,&cbrush);returncbrush;// TODO: Return a different brush if the default is not desiredreturnhbr;}

效果图

![](https://www.ccppcoding.com/wp-content/uploads/011909431337347.png)

有个现象当单击1个按钮时 部分按钮会被隐藏

代码::用位图 设置对话对话框的背景色


resources 导入1个bitmap位图// mfcDlg.h : header file// Implementationprotected:HICON m_hIcon;CBrushm_BKBrush;//画刷**::OnInitDialog()**// TODO: Add extra initialization hereCBitmap*pBitmap=newCBitmap;ASSERT(pBitmap);pBitmap->LoadBitmap(IDB_BITMAP1);//载入位图资源m_BKBrush.CreatePatternBrush(pBitmap);//创建位图画刷deletepBitmap;**::OnCtlColor(CDC*pDC,CWnd*pWnd,UINTnCtlColor)**// TODO: Change any attributes of the DC hereif (nCtlColor==CTLCOLOR_DLG)return (HBRUSH)m_BKBrush.GetSafeHandle();//返回创建的位图画刷// TODO: Return a different brush if the default is not desired

效果图

![](https://www.ccppcoding.com/wp-content/uploads/011909454307446.jpg)

关联picDialog Shape



来自为知笔记(Wiz)



原文链接: https://www.cnblogs.com/xe2011/p/3885696.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/140101

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月11日 上午7:09
下一篇 2023年2月11日 上午7:26

相关推荐