Einzelnen Beitrag anzeigen

gsmgrufti

Registriert seit: 14. Sep 2006
Ort: Nürnberg
23 Beiträge
 
Delphi 2006 Professional
 
#3

Re: TGroupBox transparent machen

  Alt 11. Apr 2007, 10:58
Du kannst dir was aus
http://www.swissdelphicenter.ch/de/showcode.php?id=1982
basteln
Müstest du nur anpassen auf Groupbox oder nimm einfach die bereits angepasste Variante von mir:
Delphi-Quellcode:
unit transgroupbox;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,ComCtrls,
  StdCtrls;
type
  TTransGroupBox = class(TGroupBox)
  private
    { Private declarations }
     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  protected
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  published
    { Published declarations }
  end;

procedure Register;

implementation

constructor TTransGroupBox.Create(AOwner: TComponent);
begin
  inherited ;
end;

procedure TTransGroupBox.CreateParams(var Params: TCreateParams);
begin
 inherited CreateParams(Params);
 Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TTransGroupBox.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  Message.Result := 1; // Prevent background from getting erased
end;


procedure TTransGroupBox.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
  tlbVisible: Boolean;
begin
  tlbVisible := (Parent <> nil) and IsWindowVisible(Handle); // Check for visibility
  if tlbVisible then ShowWindow(Handle, SW_HIDE); // Hide-Move-Show strategy...
  inherited SetBounds(ALeft, ATop, AWidth, AHeight); // ... to prevent background...
  if tlbVisible then
  begin
   ShowWindow(Handle, SW_SHOW); // ... from getting copied
   Parent.repaint;
  end;
 
end;

procedure Register;
begin
  RegisterComponents('Transparenz', [TTransGroupBox]);
end;

end.
  Mit Zitat antworten Zitat