我正在尝试制作全屏透明无边框窗口,并在其上完美显示文本。文本背景应该是透明的,但不是实际的字体。问题是当我不执行 SetWindowRgn 时,我只能看到 TextOut 显示。我不知道我做错了什么:(
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance;
DWORD Flags1 = WS_EX_COMPOSITED | WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST | WS_EX_TRANSPARENT;
DWORD Flags2 = WS_POPUP;
hWnd = CreateWindowEx(Flags1, szWindowClass, szTitle, Flags2, 0, 0, 1920, 1200, 0, 0, hInstance, 0);
if(!hWnd)return FALSE;
HRGN GGG = CreateRectRgn(0, 0, 0, 0);
SetWindowRgn(hWnd, GGG, false);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
DeleteObject(GGG);
return TRUE;
}
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, 50, 50, L"MY TEXT", lstrlen(L"MY TEXT"));
EndPaint(hWnd, &ps);