![]() // Mit dem
folgenden Code kann man eine Farbe der Form und aller ihrer // Querverweis: Formen mittels "Alpha Blending" transparent darstellen // ACHTUNG!
Die Funktion ist erst ab W2000 verfügbar! const LAYERED = 524288; procedure Transparenz(h: THandle; Farbe: TColor); var m: Thandle; f: function(hwnd: HWND; crKey: DWord; bAlpha: Byte; dwFlags: Longint): Longint; stdcall; begin m := LoadLibrary('User32.dll'); if m <> 0 then begin @f := GetProcAddress(m, 'SetLayeredWindowAttributes'); if @f <> nil then begin SetWindowLong(h, GWL_EXSTYLE, GetWindowLong(h, GWL_EXSTYLE) or LAYERED); f(h, ColorToRGB(Farbe), 0, 1); freelibrary(m); end; end; end; procedure Normal(h: THandle); begin SetWindowLong(h, GWL_EXSTYLE, GetWindowLong(h, GWL_EXSTYLE) and not LAYERED); end; // Tranzparenz einstellen procedure TForm1.SpeedButton1Click(Sender: TObject); begin Transparenz(handle, color); end; // Tranzparenz abschaltehn procedure TForm1.SpeedButton2Click(Sender: TObject); begin Normal(handle); end; |
Zugriffe seit 6.9.2001 auf Delphi-Ecke