I found the answer by myself, in a post in the fórum. I says something about
moving in one unit the other unit reference from the uses clause to the
implementation section, for example:

 

(UNIT 2)

Implementation

  uses Unit1;

 

Now I tryed writting both uses on implementation section and also works
well. Whats the diference between uses clause and implementation clause? 

 

Regards 

De: German C. Basisty [mailto:[EMAIL PROTECTED] 
Enviado el: sábado, 14 de julio de 2007 04:55 p.m.
Para: lazarus@miraclec.com
Asunto: RE: [lazarus] Call a form from another form

 

Hi, me again!

 

How do I do to avoid a circular unit reference? What If after form2 shows
up, I want a button to make it disappear and show form1 again? I tryed
adding Unit1 to the uses clause of Unit2, but it doesnt compile showin an
error about circular unit reference.

 

Rest regards

 

De: Charl van Jaarsveldt [mailto:[EMAIL PROTECTED] 
Enviado el: sábado, 14 de julio de 2007 04:41 p.m.
Para: lazarus@miraclec.com
Asunto: Re: [lazarus] Call a form from another form

 

You should have a unit for form1 called unit1 (if not haven't changed the
name), and another unit, called unit2 for form2.
If you look at unit1 in the editor, you will see that it starts like:

unit Unit1; 

{$mode objfpc}{$H+}

interface

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

Now, add unit2 to the uses list so that it is:
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, unit2;

This is assuming you haven't changed the names yet. :-)

Basically, the uses clause tells the compiler which units, or source files,
you are using in the one you are busy with, so for every unit you use, you
need to specify it in the uses clause. 

Hope it helps,
Charl

On 7/14/07, German C. Basisty <[EMAIL PROTECTED] > wrote:

It does not compile, sorry. I think I forgot to add the unit of form2. I
really dont know hot to do that, may you please send me an example? J 

Regards

 

De: Charl van Jaarsveldt [mailto:[EMAIL PROTECTED] 
Enviado el: sábado, 14 de julio de 2007 03:59 p.m.
Para: lazarus@miraclec.com
Asunto: Re: [lazarus] Call a form from another form

 

Hello,

When you say it doesn't work, what do you mean? It does not compile, or it
does not work the way you expected?

If compiling is a problem, it could be that you forgot to add the unit of
form2 in the uses clause for the unit of form1. 

Charl

On 7/14/07, German C. Basisty <[EMAIL PROTECTED]> wrote: 

Hi!

 

This is a very newby question, but you have to understand I'm a Linux c++
(console) developer, not familiar with Delphi.

I could install Lazarus, tryed a few examples, and now I'm trying to call a
form from another form. So I designed a form (Form1) with a button and a
second form, but it starts on a diferent unit or something. I want to make
the button on form1 call form2, but it seems this button does not know form2
exist. The statement I used was something like

 

procedure TForm1.Button1Click(Sender: TObject);

begin

  Form1.Hide;

  Form2.Show;

end;

 

This does not work J

 

Can someone tell me where to start reading?? 

 

Best regards  




-- 
"I love deadlines. I especially love the whooshing sound they make as they
fly by." - Douglas Adams 




-- 
"I love deadlines. I especially love the whooshing sound they make as they
fly by." - Douglas Adams 

Reply via email to