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.