Recent

Author Topic: call a form from another and vice versa  (Read 6531 times)

fachamix

  • Newbie
  • Posts: 6
call a form from another and vice versa
« on: January 01, 2010, 12:10:37 am »
I have 2 forms Form1 and Form2

I need them to interact, Form1 needs to change some things in Form2 , and Form2 needs to change some things in Form1

In the code of Form1, in the "uses" declaration I add the form2.pas unit called form2
And works perfect, I can use Form2 from Form1

BUT!!!!!!!!!!!!!!

when I add form1 in the "uses" declaration of Form2 I get a Compiler ERROR saying something about CIRCULAR REFERENCE!!!!!!!!!!!!!!!!!
I understand the circular reference, but i dont know how to do what i want

davesimplewear

  • Sr. Member
  • ****
  • Posts: 319
    • Davids Freeware
Re: call a form from another and vice versa
« Reply #1 on: January 01, 2010, 08:59:12 am »
perhaps instead of using 2 forms you could use one with either a Notebook or pageControl and hide the tabs? I don't know of any way to overcome the circular reference. Good Luck
All things considered insanity seems the best option

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: call a form from another and vice versa
« Reply #2 on: January 01, 2010, 10:29:46 am »
You can move the uses of one or two units to the implementation section.

mmab

  • Jr. Member
  • **
  • Posts: 89
Re: call a form from another and vice versa
« Reply #3 on: January 01, 2010, 02:30:48 pm »
for ex.
you have 2 forms with units,
unit1
unit2

first one should look like
Code: [Select]
unit Unit1;

{$mode delphi}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, StdCtrls,unit2,

....

thesecond one should look like


Code: [Select]
nit Unit2;

{$mode delphi}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, StdCtrls;

....

implementation
  uses unit1;




fachamix

  • Newbie
  • Posts: 6
Re: call a form from another and vice versa
« Reply #4 on: January 01, 2010, 03:10:38 pm »
for ex.
you have 2 forms with units,
unit1
unit2

first one should look like
Code: [Select]
unit Unit1;

{$mode delphi}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, StdCtrls,unit2,

....

thesecond one should look like


Code: [Select]
nit Unit2;

{$mode delphi}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ComCtrls, StdCtrls;

....

implementation
  uses unit1;





this worked perfectly ... thanks a lot people, thanks!!!!!!!!!!

fachamix

  • Newbie
  • Posts: 6
Re: call a form from another and vice versa
« Reply #5 on: January 01, 2010, 09:36:16 pm »
where did you learn the solution ??? what lecture do you recomend me ?

mmab

  • Jr. Member
  • **
  • Posts: 89
Re: call a form from another and vice versa
« Reply #6 on: January 05, 2010, 02:49:37 am »

 
   I read and googled a lot on pascal starting from delphi. And I also read other people's codes.
  thats all.
 

 

TinyPortal © 2005-2018