模态对话框 - 按钮背景色透明
时间:2010-04-30 来源:cjjchong
1.头文件包含
#include "TransParentButton.h"
#include "PaintCap.h"
2.头文件中重载窗口的init
1)classic A public CDialog的 2)// Implementation CCaptionPainter m_Cap;
此处重点:假设你在VC中将CONTROL_ID对应的 member为 m_Next; 则修改修改CButton m_Next 为CTransParentButton n_Next; 并将其从/{{AFX_DATA(XXXX) //}}AFX_DATA中移到//Implementation下面
// Generated message map functions //{{AFX_MSG(CAutorunDlg) virtual BOOL OnInitDialog();
3.cpp文件中重写OnInitDialog() BOOL XXXXX::OnInitDialog() { CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } }
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here
CString str;// = "WAG200G"; str.LoadString(IDS_WIZARD_TITLE); m_Cap.SetCaption(str); m_Cap.Install(this, WM_MYPAINTMESSAGE); m_Cap.UpdateFrameTitle(this->m_hWnd);
return TRUE; // return TRUE unless you set the focus to a control }
2.头文件中重载窗口的init
1)classic A public CDialog的 2)// Implementation CCaptionPainter m_Cap;
此处重点:假设你在VC中将CONTROL_ID对应的 member为 m_Next; 则修改修改CButton m_Next 为CTransParentButton n_Next; 并将其从/{{AFX_DATA(XXXX) //}}AFX_DATA中移到//Implementation下面
// Generated message map functions //{{AFX_MSG(CAutorunDlg) virtual BOOL OnInitDialog();
3.cpp文件中重写OnInitDialog() BOOL XXXXX::OnInitDialog() { CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } }
// Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here
CString str;// = "WAG200G"; str.LoadString(IDS_WIZARD_TITLE); m_Cap.SetCaption(str); m_Cap.Install(this, WM_MYPAINTMESSAGE); m_Cap.UpdateFrameTitle(this->m_hWnd);
return TRUE; // return TRUE unless you set the focus to a control }
相关阅读 更多 +