06/08/2022

This is just a note to myself, since it took me a while to find this. If you want to make a nonsquare window in GDI, you can use SetWindowRgn. You can also use WS_EX_LAYERED to make the window transparent. Below is sample code. I found this on: https://blog.karatos.in/a?ID=00750-fc6e0241-fb3f-4986-945d-578f83091a28


HRGN rgn = CreateEllipticRgn(100, 100, 500, 500);
HWND hWnd = CreateWindowEx(WS_EX_LAYERED | WS_EX_TOOLWINDOW, szWindowClass, szTitle, 0,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

if (!hWnd)
{
return FALSE;
}
SetWindowLongW(hWnd, GWL_STYLE, 0);
SetWindowRgn(hWnd, rgn, true);
SetLayeredWindowAttributes(hWnd, RGB(255, 0, 0), 180, LWA_ALPHA);

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);