![]() |
Ein beliebiges Fenster transparent schalten
Basierend auf
![]() Ein beliebiges Fenster transparent schalten Funktion:
Delphi-Quellcode:
Beispielaufruf, um das Fenster mit dem Handle 67034 mit einer AlphaBlendValue von 150 transparent zu schalten:
function MakeWindowTransparent(Wnd: HWND; nAlpha: Integer = 10): Boolean;
type TSetLayeredWindowAttributes = function(hwnd: HWND; crKey: COLORREF; bAlpha: Byte; dwFlags: Longint): Longint; stdcall; const // Use crKey as the transparency color. LWA_COLORKEY = 1; // Use bAlpha to determine the opacity of the layered window.. LWA_ALPHA = 2; WS_EX_LAYERED = $80000; var hUser32: HMODULE; SetLayeredWindowAttributes: TSetLayeredWindowAttributes; begin Result := False; // Here we import the function from USER32.DLL hUser32 := GetModuleHandle('USER32.DLL'); if hUser32 <> 0 then begin @SetLayeredWindowAttributes := GetProcAddress(hUser32, 'SetLayeredWindowAttributes'); // If the import did not succeed, make sure your app can handle it! if @SetLayeredWindowAttributes <> nil then begin // Check the current state of the dialog, and then add the WS_EX_LAYERED attribute SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) or WS_EX_LAYERED); // The SetLayeredWindowAttributes function sets the opacity and // transparency color key of a layered window SetLayeredWindowAttributes(Wnd, 0, Trunc((255 / 100) * (100 - nAlpha)), LWA_ALPHA); Result := True; end; end; end;
Delphi-Quellcode:
Die Transparenz eines beliebigen Fensters entfernen
procedure TForm1.Button1Click(Sender: TObject);
begin MakeWindowTransparent(67034, 150); end; Funktion:
Delphi-Quellcode:
Beispielaufruf, um die Transparenz des Fensters mit dem Handle 67034 zu entfernen:
procedure MakeWindowOpaque(Wnd: HWND);
const WS_EX_LAYERED = $80000; Begin // remove the layer from our window SetWindowLong(Wnd, GWL_EXSTYLE, GetWindowLong(Wnd, GWL_EXSTYLE) And Not WS_EX_LAYERED); // redraw complete window RedrawWindow(Wnd, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ALLCHILDREN); End;
Delphi-Quellcode:
Hinweis: getestet unter WindowsXP Pro SP2
procedure TForm1.Button2Click(Sender: TObject);
begin MakeWindowOpaque(67034); end; [edit=Matze]Ergänzungen von shmia, basierend auf Source-Code des ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:24 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz