RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomForm.OnShow Event

Occurs when the form is shown (that is, when its Visible property is set to true).

Pascal
property OnShow: TNotifyEvent;
C++
__property TNotifyEvent OnShow;

Use OnShow to perform special processing when the form is shown (that is, when the form's Visible property is set to true).  

C++ Examples: 

 

/*
This project requires a Page Control.  You will need to
populate the Page Control by right clicking and selecting
New Page from the context menu. As the tabs are selected by
the user, the Page Control OnChange event fires, which
causes the form caption to display the captions of each of
the TTabSheets attached to the Page Control.
Note the use of the Form’s OnShow event handler to set the
caption when the form first appears.  This occurs before
any changes trigger the OnChange event of the Page Control.
*/
void __fastcall TForm1::PageControl1Change(TObject *Sender)
{
  Caption = AnsiString("Now working on tab: " + PageControl1->ActivePage->Caption);
}

void __fastcall TForm1::FormShow(TObject *Sender)
{
  PageControl1Change(Sender);
}

 

Delphi Examples: 

{
This project requires a Page Control.  You will need to
populate the Page Control by right clicking and selecting
New Page from the context menu. As the tabs are selected by
the user, the Page Control OnChange event fires, which
causes the form caption to display the captions of each of
the TTabSheets attached to the Page Control.
Note the use of the Form’s OnShow event handler to set the
caption when the form first appears.  This occurs before
any changes trigger the OnChange event of the Page Control.
} 
procedure TForm1.PageControl1Change(Sender: TObject);
begin
  Caption := ' Now working on tab:  ' + PageControl1.ActivePage.Caption;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  PageControl1Change(Sender);
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!