Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/143.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ UpdateLayeredWindow在windows 7中失败GetLastError 87_C++_Windows_Mfc_Gdi+ - Fatal编程技术网

C++ UpdateLayeredWindow在windows 7中失败GetLastError 87

C++ UpdateLayeredWindow在windows 7中失败GetLastError 87,c++,windows,mfc,gdi+,C++,Windows,Mfc,Gdi+,窗口创建代码: LPCTSTR lpszClassName=AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,AfxGetApp()->LoadStandardCursor(IDC_箭头), (HBRUSH)GetStockObject(透明),NULL); 如果(PngID) GdiplusHelper::LoadImageFromResource(m_bkImage,PngID,_T(“PNG”); 如果(HoverPngID) GdiplusHelpe

窗口创建代码:

LPCTSTR lpszClassName=AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW,AfxGetApp()->LoadStandardCursor(IDC_箭头),
(HBRUSH)GetStockObject(透明),NULL);
如果(PngID)
GdiplusHelper::LoadImageFromResource(m_bkImage,PngID,_T(“PNG”);
如果(HoverPngID)
GdiplusHelper::LoadImageFromResource(m_hoverImage,HoverPngID,_T(“PNG”);
m_Width=m_bkImage.GetWidth();
m_Height=m_bkImage.GetHeight();
BOOL ret=CWnd::Create(lpszClassName,NULL,WS_重叠| WS_可见,正确(x,y,x+m_宽度,y+m_高度),pParentWnd,nID);
添加_EX_样式(GetSafeHwnd(),WS_EX_LAYERED);
绘图代码:

BLENDFUNCTION pb_uz={0};
pb_u.AlphaFormat=AC_SRC_ALPHA;
pb_u.BlendOp=AC_SRC_OVER;
pb_u.BlendFlags=0;
pb_u.SourceConstantAlpha=255;
hdcdc=::GetDC(GetSafeHwnd());
HDC mem_dc=创建兼容的dc(dc);
HBITMAP HBITMAP=CreateCompatibleBitmap(dc,m_宽度,m_高度);
CPoint pt_(0,0);
CSize size_uu(m_宽度,m_高度);
::选择对象(mem_dc_,hBitmap);
如果(!m_bkImage.IsNull())
m_bkImage.Draw(mem_dc_,0,0,m_宽度,m_高度);
如果(m_isHover)
{
如果(!m_hoverImage.IsNull())
m_hoverImage.Draw(mem_dc_,0,0,m_宽度,m_高度);
}
if(!::UpdateLayeredWindow(GetSafeHwnd(),dc,nullptr,&size\u,mem\u dc\u,&pt\u,0,&pb\u,ULW\u ALPHA))
{

LOGE(“UpdateLayeredWindow错误:”错误87表示“参数不正确。”。不同之处可能是,
WS_EX_LAYERED
仅支持windows 8之前的顶级窗口。是的,WS_EX_LAYERED需要win8之前的顶级窗口。但是在我的代码中,我创建了一个窗口,使用WS_OVERLAPPED | WS|u VISIBLE,父类为CWnd。我真的不知道为什么…@zero您正在使用父窗口创建窗口指定:
CWnd::Create(…,pParentWnd…);
如果
pParentWnd
不为空,则使其成为子窗口。正如MikeCAT所说,子窗口不能在Win7中使用
WS_EX_LAYERED
。@tom因为没有
操作符,所以保证有交错代码