<div dir="ltr">You may need to post your application's .lpr as well... We don't know if the forms are created in there or not.<br><br>I am not sure you can assign "Appliction" as the parent of a form... isn't it just "null" or "self"? Smarter people will know that...<br>
<br>ie.<br>Form2 := TForm2.Create (self); <br>or<br>Form2 := TForm2.Create (null); <br>
<br>In the .lpr file the command is different too...<br>Application.CreateForm (TForm2, Form2);<br><br>Regards,<br>-Reenen<br><br><br><div class="gmail_quote">2008/10/1 Usuario Anónimo <span dir="ltr"><<a href="mailto:usuarioanonimomysql@gmail.com">usuarioanonimomysql@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr"><div>Sometimes in a simple applicattion whith a principal form and several secondary forms accesed by a TMainMenu I get the error: <br>
<br>Access violation. <br><br>Press Ok to ignore and risk data corruption. <br>
Press Cancel to kill the program. <br><br>when I branch between forms. Anybody help me? <br><br>My application: </div>
<div> </div>
<div>unit Unit1; <br><br>{$mode objfpc}{$H+} <br><br>interface <br><br>uses <br> Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Menus; <br><br>type <br><br> { TForm1 } <br><br> TForm1 = class(TForm) <br>
MainMenu1: TMainMenu; <br> MenuItem1: TMenuItem; <br> MenuItem2: TMenuItem; <br> MenuItem3: TMenuItem; <br> MenuItem4: TMenuItem; <br> procedure MenuItem1Click(Sender: TObject); <br> procedure MenuItem2Click(Sender: TObject); <br>
procedure MenuItem3Click(Sender: TObject); <br> private <br> { private declarations } <br> public <br> { public declarations } <br> end; <br><br>var <br> Form1: TForm1; <br><br>implementation <br><br>uses Unit2, Unit3, Unit4; <br>
<br>{ TForm1 } <br><br>procedure TForm1.MenuItem1Click(Sender: TObject); <br>begin <br> Form2 := TForm2.Create (Application); <br> try <br> Form2.ShowModal; <br> finally <br> Form2.Free; <br> end; <br>end; <br><br>procedure TForm1.MenuItem2Click(Sender: TObject); <br>
begin <br> Form3 := TForm3.Create (Application); <br> try <br> Form3.ShowModal; <br> finally <br> Form3.Free; <br> end; <br>end; <br><br>procedure TForm1.MenuItem3Click(Sender: TObject); <br>begin <br> Form4 := TForm4.Create (Application); <br>
try <br> Form4.ShowModal; <br> finally <br> Form4.Free; <br> end; <br>end; <br><br>initialization <br> {$I unit1.lrs} <br><br>end. </div>
<div> </div>
<div>Unit2.pas</div>
<div> </div>
<div>unit Unit2; <br><br>{$mode objfpc}{$H+} <br><br>interface <br><br>uses <br> Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Menus; <br><br>type <br><br> { TForm2 } <br><br> TForm2 = class(TForm) <br>
MainMenu1: TMainMenu; <br> MenuItem1: TMenuItem; <br> procedure MenuItem1Click(Sender: TObject); <br> private <br> { private declarations } <br> public <br> { public declarations } <br> end; <br><br>var <br>
Form2: TForm2; <br><br>implementation <br><br>{ TForm2 } <br><br>procedure TForm2.MenuItem1Click(Sender: TObject); <br>begin <br> Close; <br>end; <br><br>initialization <br> {$I unit2.lrs} <br><br>end. </div>
<div> </div>
<div>Regards.</div></div>
<br>_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lazarus.freepascal.org">Lazarus@lazarus.freepascal.org</a><br>
<a href="http://www.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://www.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>o__<br>,_.>/ _<br>(_)_\(_)_______<br>...speed is good<br>_______________<br>I believe five out of four people have a problem with fractions.<br>
</div>