Application with 2 forms lazarus / 7-LCL ---------------------------------------------------------------------- No_name · 2004-07-19 16:24 Hello, I'm new at Lazarus and I've a problem: in my application there are 2 forms: the main and another. How can I show  the second after menu click ? I've tried with: Form2.Create; Form2.Show; but always said me "Access violation" Best regard,    by E0S ---------------------------------------------------------------------- Giuseppe Ridinò · 2004-07-21 13:28 My application has 3 forms and I have no problems.  :arrow: Just use Form2.Show. Form2.Create isn't necessary if you create the Form2 with Lazarus IDE. You need to use Form2.Create only if you build it in run-time. ---------------------------------------------------------------------- Vincent Snijders · 2004-07-21 13:40 Forms are normaly autocreated and a reference is stored in a global variable (Form2 in your case), if you don't indicate otherwise as pepecito mentioned. Also remember a form is an object. So to create a form at run-time, you have to do something like: Code: [Select] var   MyForm2: TForm2; begin   MyForm2 := TForm2.Create;   MyForm2.ShowModal;   MyForm2.Free; //if you use Show, be sure to free it in an OnClose event. end; ---------------------------------------------------------------------- trlpht · 2004-07-26 03:10 --- snipped --- So to create a form at run-time, you have to do something like: Code: [Select] var   MyForm2: TForm2; begin   MyForm2 := TForm2.Create;   MyForm2.ShowModal;   MyForm2.Free; //if you use Show, be sure to free it in an OnClose event. end; The access violation occurs when you are not sure of who owns the form.  Do you not need to pass a parameter to the create method to specify this?  I was getting this error and it left me when I created a form in this manner: Code: [Select] ... begin MyForm2.Create(Application); MyForm2.Show end; ... Regards ---------------------------------------------------------------------- Marc · 2004-07-29 09:15 Code: [Select] ... begin MyForm2.Create(Application); MyForm2.Show end; ... You cant use the variable MyForm2 to create a class. The variable has first to be assigned. So use  Code: [Select]MyForm2 := TMyForm2.Create(Application); Contrary to C++ the MyForm2 variable is just a pointer to an object (which has to be created first). Declaring a objectr variable doesn't mean that it is created.