问题描述
所以,我有一个WINDOWCLASSX,我想设置的背景,包括alpha通道,但我只看到一个RGB宏;没有RGBA。
So, I have a WINDOWCLASSX that I want to set the background to, including the alpha channel, but I only saw an "RGB" macro; no RGBA.
那么如何在hbrBackground上设置alpha呢?这是我的代码:
So how do I set alpha on hbrBackground? Here is my code:
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (GetModuleHandle(0), MAKEINTRESOURCE(IDI_MYAPP));
wincl.hIconSm = LoadIcon (GetModuleHandle(0), MAKEINTRESOURCE(IDI_MYAPP));
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME);
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
在最后一行,我想要设置alpha。
On that last line, I want to be able to set alpha.
- 感谢任何帮助。
-Thanks for any help.
推荐答案
窗口类。您必须将 WS_EX_LAYERED
样式应用于窗口,然后使用 SetLayeredWindowAttributes()
或 UpdateLayeredWindow()
设置窗口的Alpha通道。有关详细信息,请阅读MSDN文档:
You cannot create an alpha channel using a background brush on the window class. You have to apply the WS_EX_LAYERED
style to the window instead and then use either SetLayeredWindowAttributes()
or UpdateLayeredWindow()
to set the window's alpha channel. Read the MSDN documentation for more details:
这篇关于如何设置WINDOWCLASSX hbrBackground alpha通道? (C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!