问题描述
我已阅读有关此主题的其他帖子,并尝试了一切建议但没有成功。我发布这个是希望有人有一小段代码,如实际工作的波纹管。
I have read other posts on this topic and tried everything suggested to no success. I am posting this in the hope that someone has a small piece of code like the bellow that actually works.
根据这里 http://msdn.microsoft.com/en-gb / library / windows / desktop / ff700543(v = vs.85).aspx
According to here http://msdn.microsoft.com/en-gb/library/windows/desktop/ff700543(v=vs.85).aspx
WS_EX_LAYERED:
WS_EX_LAYERED :
该窗口是 分层
窗口。如果窗口具有 类
样式 CS_OWNDC 或 CS_CLASSDC 。
The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.
Windows 8: 顶级窗口和子窗口支持 WS_EX_LAYERED 风格。以前的Windows版本仅支持顶级窗口 WS_EX_LAYERED 。
Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions supportWS_EX_LAYERED only for top-level windows.
因此,鉴于我在Windows 8.1机器上,我希望以下代码能够正常工作。但它无法创建窗口,也没有说明原因。我假设我正在做一些愚蠢的事情,或者还有其他的"魔法"。我必须设置或不设置的标志
设置为使其工作。
So, given that I am on a Windows 8.1 box I would expect the following code to work. But it fails to create the window and gives no indication of why. I am assuming I am doing something dumb or there are other "magic" flags that I have to set or not set to get this to work.
WNDCLASSEX winClass;
ZeroMemory( &winClass, sizeof( winClass ) );
winClass.lpszClassName = L"FOO";
winClass.cbSize = sizeof(WNDCLASSEX);
winClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
winClass.lpfnWndProc = WindowProc; // Assume this function exists and works
RegisterClassEx( &winClass ); // This works find
HWND parentHWnd = // Get this from somewhere, elided but assume it's a normal top level window
HWND childHWnd = CreateWindowEx(
WS_EX_LAYERED,
L"FOO", // Class name registered above
L"SAD_WINDOW",
WS_CHILD | WS_VISIBLE,
0, 0,
300, 300,
parentHWnd,
0,
0,
0 );
if( childHWnd == nullptr )
{
DWORD error = GetLastError( ); // This return 0 - Not so helpful!
}
推荐答案
这篇关于WS_EX_LAYERED和WS_CHILD透明子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!