I would like to know where is the formshow in delphi 2010 as when I can only see a formcreate in my project.
The reason I am asking is because I need to add Randomize in the FormShow event handler, as shown below:
procedure TfrmWinnaSpree.FormShow(Sender: TObject);
begin
Randomize;
end;
You create the event handler the same way you create almost every event handler in Delphi, by double-clicking the method in the
Eventstab of theObject Inspector.Click on the form itself (not any control on the form), then switch to the
Object Inspector. Click on theEventstab, and then scroll down to theOnShowevent. Double-click in the right half next to the event name, and the IDE will create a new, empty event handler and put the cursor in the right place to start writing code.However,
FormShowis the wrong place to callRandomize, becauseFormShowexecutes every time your form is shown, and that can happen more than once. Here’s an example (it assumes two forms, Form1 and Form2, autocreated as usual in the .dpr file with the default variable names, which of course is a bad idea – this is to demonstrate a problem with your question’s purpose):Run the program and click
TForm1.Button1multiple times; you’ll see the In FormShow message every other time you do so.The proper places for a call to Randomize are:
in an initialization section of your main form’s unit
in your project source (.dpr) file