Follow the code below:
type
TfObject = class(TForm)
private
procedure FormShow(Sender : TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
public
constructor Create(AOwner : TComponent); override;
{ Public declarations }
end;
Create code:
constructor TfObject.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
Position := TPosition.poScreenCenter;
WindowState := wsNormal;
KeyPreview := true;
AlphaBlend := true;
AlphaBlendValue := 0;
BorderStyle := bsSizeable;
OnShow := FormShow;
OnKeyDown := FormKeyDown;
OnClose := FormClose;
end;
The problem is this, according to what I know related to Delphi with OO, I could use this way to be able to inherit the methods contained in the Parent class, but when I do this, I can not use the inherited
in the child class, which is in this case the form that is inheriting from TfObject
.
I've found that by doing the class this way, I can usually use the form's methods, but when I put it into the form's methods ( OnShow
, OnClose
, OnKeyDown
) to receive its methods, it behaves as if the child class is doing this.
Now my question ...
How do I get my class TForm
to assign its form methods and I just inherit them when I implement a method ( OnShow
, OnClose
, OnKeyDown
)?
Example:
procedure TForm1.FormShow(sender : TObject);
begin
//faz algo
inherited;
//faz algo
end;