Ver Mensaje Individual
  #17  
Antiguo 13-09-2007
Avatar de José Luis Garcí
[José Luis Garcí] José Luis Garcí is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Las Palmas de G.C.
Posts: 1.372
Reputación: 25
José Luis Garcí Va camino a la fama
Si, te mado de nuevo el código completo, para ver si vez el fallo

Código Delphi [-]
unit UCCDShadow;

interface

uses
  Windows, Messages, SysUtils, Controls, ComCtrls,Classes, Forms, Graphics;

type
  TCCDShadow = class(TComponent)
  private
    { Private declarations }
    FActive: Boolean;
    FDeph: Integer;
    FColor: Tcolor;
    ParentForm: TForm;
    procedure SetActive(Value: Boolean);
    procedure Setdeph(value : Integer);
    procedure Setcolor(Value: TColor);
  protected
    { Protected declarations }
    procedure ShadowDraw;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure loaded; override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
  published
    { Published declarations }
    property Active: Boolean read FActive write SetActive default True;
    property Deph: Integer read FDeph write SetDeph default 3;
    property Color: Tcolor read FColor write SetColor default clAqua;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('CLub Delphi', [TCCDShadow]);
end;

constructor TCCDShadow.Create(AOwner: TComponent);
var
  I: Integer;
begin
  if not (AOwner is TForm) then
    raise Exception.Create('The owner must be a Form');
  ParentForm := TForm(AOwner);
  for I := 0 to Pred(ParentForm.ComponentCount) do
    if ParentForm.Components[i] is TCCDShadow then
      raise Exception.Create('Only one TCCDShadow can exist in a Form');
  inherited Create(AOwner);
  Fcolor := clAqua;
  Fdeph := 3;
  FActive := True;
end;

procedure TCCDShadow.SetActive(Value: Boolean);
begin
  if FActive <> Value then
  begin
    FActive := Value;
    ShadowDraw
  end
end;

Procedure TCCDShadow.SetColor(value : TColor);
begin
  if (FColor <> value) then
  begin
    FColor:= value;
    ShadowDraw
  end
end;

procedure TCCDShadow.SetDeph(value : Integer);
begin
  if (Fdeph <> value) then
  begin
    FDeph:= value;
    ShadowDraw
  end
end;

procedure TCCDShadow.ShadowDraw;
var
  I: Integer;
  rect: TRect;
  old: TColor;
  Component : TComponent;

begin
  if not FActive then
    Exit;
  ParentForm.Repaint;
  for I := 0 to ParentForm.ControlCount -1 do
    with ParentForm do
    begin
      Component:=Components[i];
      if Component is TControl then
      begin
       rect := Controls[i].BoundsRect;
       canvas.fillrect(rect);
       rect.Left := rect.Left + FDeph;
       rect.Top := rect.Top + FDeph;
       rect.Right := rect.Right + FDeph;
       rect.Bottom := rect.Bottom + FDeph;
       old := Canvas.brush.color;
       canvas.brush.Color :=  Fcolor;
       canvas.fillrect(rect);
       canvas.brush.Color := old;
       Controls[i].Repaint
      end
    end
end;

procedure TCCDShadow.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent,Operation);
  { Cada que agregamos un control o eliminamos un control de la forma,
    redibujamos las sombras }
  ShadowDraw;
end;

procedure TCCDshadow.loaded;
begin
  inherited;
  ShadowDraw;
end;

end.
__________________
Un saludo desde Canarias, "El abuelo Cebolleta"
Responder Con Cita