gdi+ 绘制背景图问题
原贴地址:http://topic.csdn.net/u/20100823/09/cd20fdb1-aea4-45e1-a674-f544f3f3b6cc.html,现在我实现了背景透明的效果,但是绘图后界面上所有的控件都被绘掉了,只剩一个背景图。
BOOL CTestSkinDlg::OnEraseBkgnd(CDC* pDC)
{
HDC hdcTemp = pDC->m_hDC;
m_hdcMemory = CreateCompatibleDC(hdcTemp);
HBITMAP hBitMap = CreateCompatibleBitmap(hdcTemp, m_BakWidth, m_BakHeight);
SelectObject(m_hdcMemory, hBitMap);
m_Blend.BlendOp=AC_SRC_OVER; //theonlyBlendOpdefinedinWindows2000
m_Blend.BlendFlags=0; //nothingelseisspecial...
m_Blend.AlphaFormat=AC_SRC_ALPHA; //...
m_Blend.SourceConstantAlpha = 255; // 窗口透明度最大为255,最小为0
HDC hdcScreen = ::GetDC(m_hWnd);
RECT rct;
GetWindowRect(&rct);
POINT ptWinPos = {rct.left, rct.top};
Graphics graph(m_hdcMemory);
Point points[] = { Point(0, 0),
Point(m_BakWidth, 0),
Point(0, m_BakHeight)};
graph.DrawImage(m_pImageBack, points,3);
SIZE sizeWindow={m_BakWidth,m_BakHeight};
POINT ptSrc={0,0};
DWORD dwExStyle=GetWindowLong(m_hWnd,GWL_EXSTYLE);
if((dwExStyle&0x80000)!=0x80000)
SetWindowLong(m_hWnd,GWL_EXSTYLE,dwExStyle^0x80000);
UpdateLayeredWindow(m_hWnd, hdcScreen, &ptWinPos, &sizeWindow, m_hdcMemory, &ptSrc, 0, &m_Blend, 2);
graph.ReleaseHDC(m_hdcMemory);
::ReleaseDC(m_hWnd,hdcScreen);
hdcScreen=NULL;
::ReleaseDC(m_hWnd,hdcTemp);
hdcTemp=NULL;
DeleteObject(hBitMap);
DeleteDC(m_hdcMemory);
m_hdcMemory=NULL;
return TRUE;
}