I have a procedure with Sender: TObject paramater
procedure TForm1.FormCreate(Sender: TObject);
How can I call this procedure again?
This version does not work:
TForm1.FormCreate(Sender: TObject);
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume that you wish to call the procedure
FormCreateof an instance of aTForm1.You can do
FormCreate(Self)orFormCreate(nil)(or you can pass anyTObjectinstance as the parameter) if you are inside theTForm1class. Otherwise, you have to writeForm1.FormCreate(Self)orForm1.FormCreate(nil)or similarly, whereForm1is the appropriate instance of theTForm1.At any rate, it is not particularly ‘elegant’ to call the
FormCreateprocedure at later times. Indeed, the name clearly suggests that the procedure is called when the form is created.If a particular piece of logic of your
FormCreatemethod is needed at other stages and you simply do not want to duplicate code, you should probably implement that piece in the form of a separate method (procedure or function) and call it inFormCreateas well as in other parts of your program, as necessary.But then, you might be better off moving that part of your business logic from
FormCreateat all. What we typically do inFormCreateis create/initialise objects that are later uninitialised/destroyed inFormDestroy(if needed). So, think carefully what you are doing inFormCreate, maybe there’s a better, logically more appropriate place for some or all of the actions you’ve implemented in this method.