UpdateLayeredWindow在别的机器上执行吧不成功
在自己的机器上测试没问题,在别的机器上(xp sp2、sp3)测试,该函数返回0,调用失败,使用GetLastError()获得0,表示没有错误发生,但就是不能显示窗体
图片是PNG的,有渐变透明效果,已经是release版本,
void SkinManager::UpdateDisplay( LPWNDINFO wndinfo,DWORD dwButton ){ if (wndinfo->hWnd){ if (bFlagRead){ if (wndinfo->lpWndType == wstring(_T("StatusWindow"))){ m_BakWidth = m_pStatusImg->GetWidth(); m_BakHeight = m_pStatusImg->GetHeight(); } if ( wndinfo->lpWndType == wstring(_T("CCWindow"))){ SkinManager::m_BakWidth = wndinfo->szWnd.cx; SkinManager::m_BakHeight = wndinfo->szWnd.cy; } ::SetWindowPos(wndinfo->hWnd, NULL, wndinfo->ptWnd.x, wndinfo->ptWnd.y,m_BakWidth, m_BakHeight,SWP_NOACTIVATE); HDC hdcTemp, m_hdcMemory, hdcScreen; PAINTSTRUCT ps; hdcTemp = BeginPaint(wndinfo->hWnd, &ps); HBITMAP hBitMap = CreateCompatibleBitmap(hdcTemp, m_BakWidth, m_BakHeight); m_hdcMemory = CreateCompatibleDC(hdcTemp);//创建与显示设备相关的内存设备上下文 SelectObject(m_hdcMemory, hBitMap); hdcScreen = GetDC (wndinfo->hWnd); //得到窗体的区域 RECT rct; GetWindowRect(wndinfo->hWnd,&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_pCCWndImg, points, 3); int iImageX =rct.right - rct.left - m_pOther->GetWidth()-10; graph.DrawImage(m_pOther,iImageX,15,200,50); //输出字符串 if (wndinfo->strResultComp !=_T("")){ FontFamily fontFamily(_T("Arial")); Gdiplus::Font font(&fontFamily, 16,FontStyleRegular, UnitPixel); PointF pointFComp(wndinfo->ptStrComp.x, wndinfo->ptStrComp.y); PointF pointFCand(wndinfo->ptStrCand.x, wndinfo->ptStrCand.y); SolidBrush solidBrush(Color(255, 255, 255, 255)); graph.SetTextRenderingHint(TextRenderingHintAntiAlias); graph.DrawString(wndinfo->strResultComp.c_str(), -1, &font, pointFComp, &solidBrush); graph.DrawString(wndinfo->strResultCand.c_str(), -1, &font, pointFCand, &solidBrush); } SIZE sizeWindow = {m_BakWidth,m_BakHeight}; POINT ptSrc = {0,0}; DWORD dwExStyle=GetWindowLong(wndinfo->hWnd,GWL_EXSTYLE); if((dwExStyle&0x80000)!=0x80000) SetWindowLong(wndinfo->hWnd,GWL_EXSTYLE,dwExStyle^0x80000); //SetWindowLong(wndinfo->hWnd,GWL_EXSTYLE,dwExStyle|=0x80000); BOOL bRet=FALSE; bRet=UpdateLayeredWindow(wndinfo->hWnd,hdcScreen,&ptWinPos, &sizeWindow,m_hdcMemory,&ptSrc,0,&m_Blend,2); DWORD err = GetLastError(); IMEDebug::DebugLog(err); EndPaint(wndinfo->hWnd, &ps); graph.ReleaseHDC(m_hdcMemory); ::ReleaseDC(wndinfo->hWnd,hdcScreen); hdcScreen=NULL; ::ReleaseDC(wndinfo->hWnd,hdcTemp); hdcTemp=NULL; DeleteDC(m_hdcMemory); m_hdcMemory = NULL; DeleteObject(hBitMap); } }}
If hdcSrc is NULL, hdcDst must be NULL.
难道是这个原因?