Show message when Tform2 is created?
问题 I want to when Tform2 is created then show a message to user. I use this code, but not work well. procedure TForm1.Button1Click(Sender: TObject); var a:TForm2; begin if a=nil then begin a := TForm2.Create(Self); a.Show; end else begin showmessage('TForm2 is created'); end; end; 回答1: That's because you declare a as a local variable. Each time you enter TForm1.Button1Click this variable will be brand new and uninitialized even though there might still be a Form2. That means that the check for