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.
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);
On that last line, I want to be able to set alpha.
-Thanks for any help.
You cannot create an alpha channel using a background brush on the window class. You have to apply the
WS_EX_LAYEREDstyle to the window instead and then use eitherSetLayeredWindowAttributes()orUpdateLayeredWindow()to set the window’s alpha channel. Read the MSDN documentation for more details:Using Layered Windows
Layered Windows