所以我使用 WinApi 的 CreateWindow 函数创建了一个窗口,但似乎无法使孔窗口透明,窗口显示为全黑或全白不透明我错过了什么?
begin
case uMsg of
WM_DESTROY:
begin
Cleanup;
PostQuitMessage(0);
Result := 0;
Exit;
end;
WM_PAINT:
begin
ValidateRect(hWnd, nil);
Result := 0;
Exit;
end;
end;
Result := DefWindowProc(hWnd, uMsg, wParam, lParam);
end;
var
wc: TWndClassEx = (cbSize: SizeOf(TWndClassEx); style: WS_EX_TRANSPARENT;
lpfnWndProc: @MsgProc; cbClsExtra: 0; cbWndExtra: 0; hInstance: 0;
hIcon: 0; hCursor: 0; hbrBackground: 0; lpszMenuName: nil;
lpszClassName: 'Window'; hIconSm: 0);
begin
wc.hInstance := GetModuleHandle(nil);
RegisterClassEx(wc);
hWindow := CreateWindow('Window', '', 0, 0, 0, 300, 300,
GetDesktopWindow, 0, wc.hInstance, nil);
if SUCCEEDED(hWindow) then
begin
ShowWindow(hWindow, SW_SHOW);
UpdateWindow(hWindow);
while GetMessage(msg, 0, 0, 0) do
begin
TranslateMessage(msg);
DispatchMessage(msg);
end;
end;