Jump to content

Opening Two Form Instances When Referencing It


Fábio Matte

Recommended Posts

Good afternoon.

 

I have a situation.

When declaring form1 within form2 in uses and then referencing an Edit or other component, the system instead of picking up information, it opens form1 instead of just picking up information from the field.

Example:

1. Form1 is already open and inside it has a Button that calls form2;

2. Inside form2 I need to load form1 Edits information, so I do so:   


Edit2.text: = Form1.Edit1.text;

  And instead of loading the data from Edit1, it opens a new instance of Form1.

 

In pure Delphi this works normally, but with Unigui, it opens a new instance.

Link to comment
Share on other sites

Hello Fabio,

 

IMHO (in my humble opinion),

Best practice : Never use circular reference as VCL.

Use instead a Common UniDataModule where you can declare all common variables (section property) :

 

1. Prepare your common variable :

 

TMyCommonDataModule=Class

Private

fmyText:string;

 

Public

Property myText:string read fmyText write fmyText;

 

end;

 

2. Send from your Form1 your Text :

MyCommonDataModule.MyText:=Form1.uniEdit1.Text;

 

3. In Form2, Retreive your Text:

Form2.uniEdit1.Text:=MyCommonDataModule.MyText;

 

With this technic all will be secure : you guarantee that variables are only for your unique session (one instance).

_____________

Good to read :

http://www.unigui.com/doc/online_help/application-forms.htm

 

Best regards.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...