Einzelnen Beitrag anzeigen

Ronny Grabo

Registriert seit: 16. Mai 2003
41 Beiträge
 
#10

Re: Neue TImage Komponente entwickeln

  Alt 13. Sep 2003, 22:47
Hallo,

hier die Komponente, laut Vorgabe, ohne Fehlerbehandlungen :
Delphi-Quellcode:
type
    TBBox = class(timage)
    private
    FBitmapOver : String;
    FBitmapLeave: String;
    FBitmapClick : String;
    MyPicture:TPicture;
    procedure MausRaus(var WinNachricht:TMessage);message CM_MOUSELEAVE;
    procedure MausRein(var WinNachricht:TMessage);message CM_MOUSEENTER;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { Private declarations }
  protected
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave:TNotifyEvent;
    FOnMouseClick: TNotifyEvent;
    procedure Click; override;
    procedure SetzeBild(Bild: TPicture);
    { Protected declarations }
  public
    { Public declarations }
  published
    property BmpOver : String read FBitmapOver write FBitmapOver;
    property BmpLeave : String read FBitmapLeave write FBitmapLeave;
    property BmpClick : String read FBitmapClick write FBitmapClick;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave
        write FOnMouseLeave;
    { Published declarations }
  end;

procedure Register;
implementation

procedure Register;
begin
  RegisterComponents('Beispiele', [TBBox]);
end;

constructor TBBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
MyPicture:=TPicture.Create;
end;

destructor TBBox.Destroy;
begin
MyPicture.Free;
inherited Destroy;
end;

procedure TBBox.SetzeBild(Bild: TPicture);
begin
MyPicture:=Bild;
Self.picture:=Bild;
end;

procedure TBBox.Click();
begin
inherited Click;
   MyPicture.LoadFromFile(FBitmapClick);
   SetzeBild(MyPicture);
end;

procedure TBBox.MausRaus(var WinNachricht:TMessage);
begin
  inherited;
  if WinNachricht.Msg=CM_MOUSELEAVE then
  MyPicture.LoadFromFile(FBitmapLeave);
  SetzeBild(MyPicture);
end;

procedure TBBox.MausRein(var WinNachricht:TMessage);
begin
  inherited;
  if WinNachricht.Msg=CM_MOUSEENTER then
  MyPicture.LoadFromFile(FBitmapOver);
  SetzeBild(MyPicture);
end;
Gruß Ronny.
---
Meine Internetseite : http://www.ronny-grabo.de
  Mit Zitat antworten Zitat