Ver Mensaje Individual
  #3  
Antiguo 14-06-2008
madmai madmai is offline
Miembro
 
Registrado: oct 2005
Posts: 117
Reputación: 19
madmai Va por buen camino
Este es el componente

Código Delphi [-]
unit PButon;

interface  uses   SysUtils, Classes, Controls, ExtCtrls,Buttons, Types, Graphics;  type   TPButon = class(TPanel)
  private     FSmallBitmap:TBitmap;     FBigOnclick:TNotifyEvent;     FBigLabel:String;
    FSmallOnclick:TNotifyEvent;
    FTag:Integer;

    procedure SetSmallBitmap (Value:TBitMap);
    procedure settag (Value:Integer);
    Procedure SetOnClick (Value: TNotifyEvent);
    Procedure SmallSetOnClick (Value: TNotifyEvent);
    procedure SetBigLabel (Value:String);
    Function GetSmallBitmap:TBitMap;
    procedure Resize; override;
    { Private declarations }   protected     { Protected declarations }   public     Big,Small:TSpeedbutton;     constructor Create(AOWner: TComponent); override;
    Destructor Destroy; override;
    { Public declarations }   published     property BigOnClick:TNotifyEvent read FBigOnclick write SetOnClick;
    property SmallOnClick:TNotifyEvent read FSmallOnclick write SmallSetOnClick;
    property SmallPicture:TBitmap read GetsmallBitmap write SetSmallBitmap;
    property BigCaption:String read FBigLabel write setBigLabel;
    property PanelTag:Integer read FTag write settag;
    { Published declarations }   end;

procedure Register;

implementation  procedure Register;
begin   RegisterComponents('Samples', [TPButon]);
end;

procedure TPbuton.settag(Value:Integer);
begin   FTag:=Value; end;
procedure TPButon.SetBigLabel (Value:String);
begin    FBigLabel:=value;   repaint; end;
procedure TPButon.SetSmallBitmap (Value:TBitMap);
begin   FSmallBitmap:=Value;   small.Glyph:=FSmallBitmap; end;
function TPButon.GetSmallBitmap:Tbitmap;
begin   Result:=small.Glyph; end;

Procedure  TPButon.SetOnClick (Value: TNotifyEvent);
begin     FBigOnClick:=Value;   Big.OnClick:=FBigOnClick;  end;
Procedure  TPButon.SmallSetOnClick (Value: TNotifyEvent);
begin   FSmallOnClick:=Value;   Small.OnClick:=FSmallOnClick;  end;

constructor TPButon.Create(AOWner: TComponent);
var   posicion : TPoint;  begin   //dfalñkds
   inherited Create(AOWner);
  FTag:=0;
  caption:='';
  width := 75;
  height:= 16;
  bevelouter := bvNone;
  posicion.X := Left;
  posicion.Y := Top;
  Big := TSpeedButton.create(Self);
  Big.Parent := Self;
  big.ClientToParent(posicion);
  big.Flat := True;
  Big.Width := width;
  Big.Height := Height;
  Small := TSpeedButton.Create(Self);
  Small.Parent := Self;
  small.ClientToParent(posicion);
  small.Flat := True;
  small.Width :=  big.Height div 2;
  small.Height := big.Height;
  small.Top := big.Top;
  small.Left := left + width - small.Width;
  BigCaption:=FBigLabel;
  small.NumGlyphs:=1;
  big.NumGlyphs:=1;
  caption:='';
  resize;

end;
procedure TPButon.Resize;
begin   inherited;
  caption:='';
  big.Height := height;
  big.Width := width;
  small.Width :=  big.Height div 2 + 2;
  small.Height := big.Height;
  small.Top:=big.Top;
  small.Left := big.Left + big.Width - small.Width;

end;

destructor TPButon.Destroy;
begin   big.Free;   small.Free;  inherited;
end;

end.

y luego cuando utilizo en mi programa el tpanel(sender) no hace caso imagino por que yo estoy utlizando el sender del bigonclick y no el del panel

gracias de antemano

Última edición por dec fecha: 14-06-2008 a las 11:10:28.
Responder Con Cita