Delphi创建透明窗口
因此,我使用WinApi的CreateWindow函数创建了一个窗口,但似乎无法使孔窗口透明,窗口显示为全黑或全白不透明,我缺少什么Delphi创建透明窗口,delphi,winapi,createwindow,Delphi,Winapi,Createwindow,因此,我使用WinApi的CreateWindow函数创建了一个窗口,但似乎无法使孔窗口透明,窗口显示为全黑或全白不透明,我缺少什么 begin case uMsg of WM_DESTROY: begin Cleanup; PostQuitMessage(0); Result := 0; Exit; end; WM_PAINT: begin Validate
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;
我已将图像用作组件的父级,并将组件设置为使用父级SetLayeredWindowAttributes()为什么不简单地创建一个普通的
TForm
并使用它的TransparentColor
/AlphaBlend
属性呢?我已经使用了一个TForm,但想知道如何动态地创建它-@KenWhite我以前使用过SetLayeredWindowAttributes(),但仍然没有结果。您设置了哪些参数?使用WS_EX_LAYERED window style(仅在Win8及更高版本上受支持)@dwrbudr:不,自windows 2000或其他版本以来,分层窗口一直受到支持。
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;