Besten Dank, aber in das MouseLeave geht der Code bei D7 nicht rein.
Ich habe versucht die PaintBox abzuleiten um MouseLeave/Enter published zu bekommen. Im FormCreate versuche ich auf die abgeleitete PaintBox zu casten, erhalte aber eine ungültige Typumwandlung:
Code:
type
TPie = Record
StartAngle, EndAngle: Double;
...
End;
...
TPaintBoxEx = class(TPaintBox)
private
FOnMouseEnter,
FOnMouseLeave: TNotifyEvent;
procedure CMMouseEnter (var mMsg : TMessage); message CM_MouseEnter;
procedure CMMouseLeave (var mMsg : TMessage); message CM_MouseLeave;
published
property OnMouseEnter: TNotifyEvent READ FOnMouseEnter WRITE FOnMouseEnter;
property OnMouseLeave: TNotifyEvent READ FOnMouseLeave WRITE FOnMouseLeave;
end;
TForm1 = class(TForm)
PaintBox1: TPaintBox;
...
private
FPieArray: TPieArray;
FMA: Double;
end;
...
implementation
{$R *.dfm}
procedure TPaintBoxEx.CMMouseEnter(var mMsg : TMessage);
begin
if Assigned(FOnMouseEnter) then FOnMouseEnter(Self);
end;
procedure TPaintBoxEx.CMMouseLeave(var mMsg : TMessage);
begin
if Assigned(FOnMouseLeave) then FOnMouseLeave(Self);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DoubleBuffered := true;
SetLength(FPieArray, 4);
...
(PaintBox1 as TPaintBoxEx).FOnMouseLeave := PaintBox1MouseLeave;
end;
procedure TForm1.PaintBox1MouseLeave(Sender: TObject);
begin
FMA := -1;
end;