![]() |
Komponente als Handle benutzen / Form1.Alphablend übertragen
Hi Delphianer,
Ich möchte auf meiner Form ein Hintergrundbild haben und buttons, memos etc. leicht transparent haben.Nun habe ich folgenden Code gefunden, mitdem man das komplette formular transparent machen konnte. 1.Ansatz
Delphi-Quellcode:
Kann ich diese Procedure auch irgendwie auf Komponenten anwenden? Hat jemand einen besseren Vorschlag, wie ich das realisieren kann, z.B. die Alphablend-Eigenschaft von TForm auf andere Komponenten übertragen kann?
type
TSetLayeredWindowAttributes = function ( hwnd : HWND; // handle to the layered window crKey : TColor; // specifies the color key bAlpha : byte; // value for the blend function dwFlags : DWORD // action ): BOOL; stdcall; const WS_EX_LAYERED = $80000; LWA_COLORKEY = 1; LWA_ALPHA = 2; procedure SetTransparentForm(AHandle : THandle; AValue : byte = 0); var Info: TOSVersionInfo; SetLayeredWindowAttributes: TSetLayeredWindowAttributes; begin //Check Windows version Info.dwOSVersionInfoSize := SizeOf(Info); GetVersionEx(Info); if (Info.dwPlatformId = VER_PLATFORM_WIN32_NT) and (Info.dwMajorVersion >= 5) then begin SetLayeredWindowAttributes := GetProcAddress(GetModulehandle(user32), 'SetLayeredWindowAttributes'); if Assigned(SetLayeredWindowAttributes) then begin SetWindowLong(AHandle, GWL_EXSTYLE, GetWindowLong(AHandle, GWL_EXSTYLE) or WS_EX_LAYERED); //Make form transparent SetLayeredWindowAttributes(AHandle, 0, AValue, LWA_ALPHA); end; end; end; procedure TForm1.Button1Click(Sender: TObject); begin SetTransparentForm(Handle,150); end; 2.Ansatz
Delphi-Quellcode:
Problem hierbei ist: Form2 wird nicht transparent, da form1 nicht transparent ist....
procedure TForm1.FormCreate(Sender: TObject);
begin Form2 := TForm2.Create(Application); Form2.Top := 0; Form2.Left := 0; Form2.Parent := Form1; Form2.AlphaBlend := true; Form2.AlphaBlendValue := 150; Form2.visible := True; end; Freue mich über jeden Ratschlag ;) Gruß, Lemming |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:48 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-2025 by Thomas Breitkreuz