1、更改图标
将ICON图标复制到资源文件中,载入工程,设置ID。
在对话框构造函数中,修改ICON的ID。
//ICON
CMFC_FRAMEDlg::CMFC_FRAMEDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFC_FRAMEDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDI_MAINFRAME); //修改成新的图标ID
}
2、直接换肤
SkinShape工具的SkinH.dll SkinH.;ib SkinH.she SkinH.h 均拷贝到工程目录下。
stdafx.h 中添加
<span style="color:#ff0000;">#include "SkinH.h"
#pragma comment(lib, "SkinH.lib")</span>
对话框调用之前添加
<span style="color:#ff0000;"> SkinH_Attach(); </span>
CMFC_FRAMEDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
3、更改背景
先载入一张图片,图片ID设置为IDB_BITMAP1;
头文件中添加定义:
<pre name="code" class="cpp">public:
CBrush m_brBk;
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
CPP文件中添加:
BOOL CTestDlg::OnInitDialog()
{
<span style="color:#ff0000;">CDialog::OnInitDialog();
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
m_brBk.CreatePatternBrush(&bmp);
bmp.DeleteObject();</span>
return TRUE; // return TRUE unless you set the focus to a control
}
添加消息映射
BEGIN_MESSAGE_MAP(CMFC_FRAMEDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
<span style="color:#ff0000;">ON_WM_CTLCOLOR()</span>
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
函数实现如下:
HBRUSH CMFC_FRAMEDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd == this)
{
return m_brBk;
}
return hbr;
}