/* Add background image */
BOOL ctooldlg::onerasebkgnd (cdc* pDC)
{
//TODO: Add Message Handler code here and/or call default value
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,0,0,700,610,m_hbkdc,0,0,700,610,srccopy);
::D Eleteobject (m_hbitmap);
::D Eletedc (m_hbkdc);
}
Return TRUE;
}
/* set control background transparent */
Hbrush ctooldlg::onctlcolor (cdc* pDC, cwnd* pWnd, UINT nctlcolor)
{
Hbrush HBR = Cdialogex::onctlcolor (pDC, pWnd, nctlcolor);
if (nctlcolor = = Ctlcolor_static)
{
Pdc->setbkmode (TRANSPARENT);//set Background Transparency
Pdc->settextcolor (RGB (255,255,0));//set the font to yellow
return (hbrush):: Getstockobject (null_brush);
}
TODO: Assuming that the default is not the desired brush, return a brush
Return hbr;
}
Achieve effects such as what you see:
Transferred from: http://www.2cto.com/kf/201305/210038.html
MFC joins background image and makes control background transparent