/*添加背景图片*/
BOOL CTOOLDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CDialog::OnEraseBkgnd(pDC);
HBITMAP m_hBitmap;
HDC m_hBkDC;
m_hBitmap = ::LoadBitmap(::GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BITMAP2));
m_hBkDC = ::CreateCompatibleDC(pDC-> m_hDC);
if(m_hBitmap && m_hBkDC)
{
::SelectObject(m_hBkDC,m_hBitmap);
::StretchBlt(pDC-> m_hDC,,,,,m_hBkDC,,,,,SRCCOPY);
::DeleteObject(m_hBitmap);
::DeleteDC(m_hBkDC);
} return TRUE;
} /*设置控件背景透明*/
HBRUSH CTOOLDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor); if(nCtlColor == CTLCOLOR_STATIC )
{
pDC->SetBkMode(TRANSPARENT);//设置背景透明
pDC->SetTextColor(RGB(,,));//设置字体为黄色
return (HBRUSH)::GetStockObject(NULL_BRUSH);
} // TODO: 如果默认的不是所需画笔,则返回另一个画笔
return hbr;
}
实现效果如下图所示: