Ich versuche die Hide-Methode von TInplaceEdit zu überschreiben um dem Benutzer die Möglichkeit zu geben zu reagieren, wenn der Editor versteckt wird.
Leider scheitern meine Versuche dahingehend, dass meine selbstgeschriebene Methode einfach nicht ins Programm compiliert werden will
Delphi-Quellcode:
TMyInplaceEdit = class(TInplaceEdit)
private
FOnHide : TNotifyEvent;
public
constructor Create(AOwner: TComponent); override;
procedure Hide;
published
property OnHide: TNotifyEvent read FOnHide write FOnHide default nil;
end;
TMyStringGrid = class(TStringGrid)
private
FMyInplaceEdit: TMyInplaceEdit;
FOnExitEdit: TMyStringGridExitEdit;
procedure OnInplaceEditorHide(Sender: TObject);
protected
function CreateEditor: TInplaceEdit; override;
public
constructor Create(AOwner: TComponent); override;
published
property OnExitEdit: TMyStringGridExitEdit read FOnExitEdit write FOnExitEdit;
end;
Delphi-Quellcode:
{ TMRStringGrid }
constructor TMyStringGrid.Create(AOwner: TComponent);
begin
inherited;
FOnExitEdit :=
nil;
end;
function TMyStringGrid.CreateEditor: TInplaceEdit;
begin
FMyInplaceEdit := TMyInplaceEdit.Create(Self);
FMyInplaceEdit.OnHide := OnInplaceEditorHide;
Result := FMyInplaceEdit;
end;
procedure TMyStringGrid.OnInplaceEditorHide(Sender: TObject);
var
s:
string;
begin
s := FMyInplaceEdit.Text;
if (Assigned(FOnExitEdit))
then
FOnExitEdit(Self, s);
end;
{ TMyInplaceEdit }
constructor TMyInplaceEdit.Create(AOwner: TComponent);
begin
inherited;
FOnHide :=
nil;
end;
procedure TMyInplaceEdit.Hide;
begin
if HandleAllocated
and IsWindowVisible(
Handle)
then
begin
Invalidate;
SetWindowPos(
Handle, 0, 0, 0, 0, 0, SWP_HIDEWINDOW
or SWP_NOZORDER
or
SWP_NOREDRAW);
if Focused
then Windows.SetFocus(Grid.Handle);
end;
if (Assigned(FOnHide))
then
FOnHide(Self);
end;
Was mache ich falsch?