- CTLCOLOR_BTN Button control
- CTLCOLOR_DLG Dialog box
- CTLCOLOR_EDIT Edit control
- CTLCOLOR_LISTBOX List-box control
- CTLCOLOR_MSGBOX Message box
- CTLCOLOR_SCROLLBAR Scroll-bar control
- CTLCOLOR_STATIC Static control
//
1. 在对话框的头文件中加入
afx_msg HBRUSH OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor);
// 2. 在对话框的cpp文件中加入
BEGIN_MESSAGE_MAP(CtransparentDlg, CDialog)
ON_WM_CTLCOLOR()
// }}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CtransparentDlg::OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
HBRUSH hBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC -> SetBkMode(TRANSPARENT);
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hBrush;
}
afx_msg HBRUSH OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor);
// 2. 在对话框的cpp文件中加入
BEGIN_MESSAGE_MAP(CtransparentDlg, CDialog)
ON_WM_CTLCOLOR()
// }}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CtransparentDlg::OnCtlColor(CDC * pDC, CWnd * pWnd, UINT nCtlColor)
{
HBRUSH hBrush = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC -> SetBkMode(TRANSPARENT);
return (HBRUSH)::GetStockObject(NULL_BRUSH);
}
return hBrush;
}