Thema: Delphi TImage --> OnMouseLeave

Einzelnen Beitrag anzeigen

Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#4

Re: TImage --> OnMouseLeave

  Alt 21. Aug 2007, 10:55
Habe mal in der Suche weiter gesucht und einen code von den Schweizern gefunden:

Delphi-Quellcode:
{
Folgende unit ist eine visuelle Komponente abgeleitet von TImage, welche
zusätzlich die 2 Ereignisse OnMouseEnter und OnMouseLeave beinhaltet.
}


{
The following unit is a visual component inherited of TImage, which has the
2 additional events OnMouseEnter and OnMouseLeave.
}


unit ImageEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  TImageEx = class (TImage)
  private
    { Private declarations }
    FOnMouseLeave: TNotifyEvent;
    FOnMouseEnter: TNotifyEvent;
    procedure CMMouseEnter(var msg: TMessage);
      message CM_MOUSEENTER;
    procedure CMMouseLeave(var msg: TMessage);
      message CM_MOUSELEAVE;
  protected
    { Protected declarations }
    procedure DoMouseEnter; dynamic;
    procedure DoMouseLeave; dynamic;
  public
    { Public declarations }
  published
    { Published declarations }
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Additional', [TImageEx]);
end;

{ TImageEx }

procedure TImageEx.CMMouseEnter(var msg: TMessage);
begin
  DoMouseEnter;
end;

procedure TImageEx.CMMouseLeave(var msg: TMessage);
begin
  DoMouseLeave;
end;

procedure TImageEx.DoMouseEnter;
begin
  if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;

procedure TImageEx.DoMouseLeave;
begin
  if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;

end.
Copyright © by SwissDelphiCenter.ch


kommt Delphi auch mit:
Zitat:
Error in module Unit1: Declaration of class TForm1 is missing or incorrect.
Ändere ich den Quelltext folgendermaßen: Füge unter Types: Form1 = class (TForm) hinzu:

Delphi-Quellcode:
{
Folgende unit ist eine visuelle Komponente abgeleitet von TImage, welche
zusätzlich die 2 Ereignisse OnMouseEnter und OnMouseLeave beinhaltet.
}


{
The following unit is a visual component inherited of TImage, which has the
2 additional events OnMouseEnter and OnMouseLeave.
}


unit ImageEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  Form1 = class (TForm)
  TImageEx = class (TImage)
  private
    { Private declarations }
    FOnMouseLeave: TNotifyEvent;
    FOnMouseEnter: TNotifyEvent;
    procedure CMMouseEnter(var msg: TMessage);
      message CM_MOUSEENTER;
    procedure CMMouseLeave(var msg: TMessage);
      message CM_MOUSELEAVE;
  protected
    { Protected declarations }
    procedure DoMouseEnter; dynamic;
    procedure DoMouseLeave; dynamic;
  public
    { Public declarations }
  published
    { Published declarations }
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Additional', [TImageEx]);
end;

{ TImageEx }

procedure TImageEx.CMMouseEnter(var msg: TMessage);
begin
  DoMouseEnter;
end;

procedure TImageEx.CMMouseLeave(var msg: TMessage);
begin
  DoMouseLeave;
end;

procedure TImageEx.DoMouseEnter;
begin
  if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;

procedure TImageEx.DoMouseLeave;
begin
  if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;

end.
meckert Delphi im Bereich "TImageEx = class (TImage)" mit:
Zitat:
Expected ':' but '=' found
und ich weiß zum einen nicht, was Delphi jetzt von mir will, weil ein = ist ja da und wo das : hin muss sagt Delphi mir ja auch nicht und des weiteren bin ich mir auch nicht ganz sicher, ob ich jetzt einfach ein neues Dokument öffnen kann und dahin den Code einfach kopieren kann. Weil ich habe nicht ganz so viel Ahnung, vom Einbinden von aus dem Internet stammenden Units, ging bisher alles über Komponente installieren, aber da es sich ja nicht um eine neue Komponente handelt, sondern ledeglich um eine Erweiterung.

mfG
Störtebeker
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat