1. 在对话框的头文件中加入
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);2. 在对话框的cpp文件中加入
1 BEGIN_MESSAGE_MAP(CtransparentDlg, CDialog)
2 ON_WM_CTLCOLOR()
3 //}}AFX_MSG_MAP
4 END_MESSAGE_MAP()
5
6 HBRUSH CtransparentDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
7 {
8 HBRUSH hBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
9
10 if(nCtlColor == CTLCOLOR_STATIC)
11 {
12 pDC->SetBkMode(TRANSPARENT);
13 return (HBRUSH)::GetStockObject(NULL_BRUSH);
14 }
15 return hBrush;
16 }
摘自网络