Science, Tech, Math › Computer Science How to Implement the OnCreate Event for a Delphi TFrame Object Adding TFrame.OnCreate Share Flipboard Email Print Implementing TFrame.OnCreate Computer Science Delphi Programming Delphi Tutorials Database Applications Advanced PHP Programming Perl Python Java Programming Javascript Programming C & C++ Programming Ruby Programming Visual Basic View More By Zarko Gajic Computer Science Expert MSCS, Computer Science, University of Osijek Zarko Gajic is experienced in SQL and has working knowledge of DB systems such as MS SQL Server, Firebird, Interbase, and Oracle. He is also proficient in XML, DHTML, and JavaScript. our editorial process Twitter Twitter Zarko Gajic Updated March 14, 2019 TFrame is a container for components; it can be nested within forms or other frames. A frame, like a form, is a container for other components. Frames can be nested within forms or other frames, and they can be saved on the Component palette for easy reuse. Missing OnCreate Once you start using frames, you'll note there's no OnCreate event you can use to initialize your frames. In short, the reason that a frame does not have a OnCreate event is there is no good time to fire the event. However, by overriding the Create method you can mimic the OnCreate event. After all, the OnCreate for Forms gets fired at the end of the Create constructor — so overriding Create for Frames is as having the OnCreate event. Here's the source code of a simple frame exposing a public property and overriding the Create constructor: unit WebNavigatorUnit;interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TWebNavigatorFrame = class(TFrame) urlEdit: TEdit; private fURL: string; procedure SetURL(const Value: string) ; public constructor Create(AOwner: TComponent) ; override; published property URL : string read fURL write SetURL; end;implementation{$R *.dfm} constructor TWebNavigatorFrame.Create(AOwner: TComponent) ;begin inherited Create(AOwner) ; //"OnCreate" code URL := 'http://delphi.about.com'; end;procedure TWebNavigatorFrame.SetURL(const Value: string) ;begin fURL := Value; urlEdit.Text := Value; end;end. The "WebNavigatorFrame" acts as a website launcher hosting an edit and a button control. Note: if you are new to frames, make sure you read the following two articles: visual component development using frames, replacing tabsheets with frames. Cite this Article Format mla apa chicago Your Citation Gajic, Zarko. "How to Implement the OnCreate Event for a Delphi TFrame Object." ThoughtCo, Aug. 27, 2020, thoughtco.com/implement-oncreate-event-delphi-tframe-object-1057878. Gajic, Zarko. (2020, August 27). How to Implement the OnCreate Event for a Delphi TFrame Object. Retrieved from https://www.thoughtco.com/implement-oncreate-event-delphi-tframe-object-1057878 Gajic, Zarko. "How to Implement the OnCreate Event for a Delphi TFrame Object." ThoughtCo. https://www.thoughtco.com/implement-oncreate-event-delphi-tframe-object-1057878 (accessed January 24, 2021). copy citation