TFormOnHide (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses two forms, each with a label and a button. When you click a button, the other form appears and the current form disappears. Also, a message appears in the label of the form that is showing, indicating that the other form is hidden. Set the OnHide event handler for each form to FormHide. This is the implementation section of TFormOnHide.pas:

Code

 
implementation

{$R *.dfm}

uses Unit2;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Show;
  Hide;
end;

procedure TForm1.FormHide(Sender: TObject);
begin
  Form2.Label1.Caption := 'Form1 is hiding';
end;

This is the implementation section of Unit2.pas:

Code

implementation

{$R *.dfm}

uses TFormOnHide;

procedure TForm2.Button1Click(Sender: TObject);
begin
  Form1.Show;
  Hide;
end;

procedure TForm2.FormHide(Sender: TObject);
begin
  Form1.Label1.Caption := 'Form2 is hiding';
end;

Uses