Jump to content

Passing Data between form


AMIT

Recommended Posts

There is no need for a special technique. Just assign them as you'd do in a regular Delphi app.

 

UniForm1.Edit1.Text:=UniForm2.Edit2.Text;

 

PS: Both forms must be valid instances at time of assignment.

 

It's not work perfectly as you said. I found it work sometime on the browser (I use Firefox), But it works perfectly on Win32.

 

Here is code I made.

 

unit Main;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics,
 Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
 uniGUIClasses, uniGUIForm, uniButton, uniGUIBaseClasses, uniEdit;

type
 TMainForm = class(TUniForm)
   UniEdit1: TUniEdit;
   UniButton1: TUniButton;
   UniButton2: TUniButton;
   UniEdit2: TUniEdit;
   procedure UniButton1Click(Sender: TObject);
   procedure UniButton2Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

function MainForm: TMainForm;

implementation

{$R *.dfm}

uses
 uniGUIVars, MainModule, Unit2;

function MainForm: TMainForm;
begin
 Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
 uniForm2.show;
end;

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
 uniForm2.Refresh;
 uniEdit1.Text:=uniForm2.UniEdit1.Text;
 uniEdit2.Text:=uniForm2.UniEdit2.Text;
end;

initialization
 RegisterMainFormClass(TMainForm);

end.


 

Here is for unit2

 

unit Unit2;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics,
 Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
 uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniEdit;

type
 TUniForm2 = class(TUniForm)
   UniEdit1: TUniEdit;
   UniEdit2: TUniEdit;
 private
   { Private declarations }
 public
   { Public declarations }
 end;

function UniForm2: TUniForm2;

implementation

{$R *.dfm}

uses
 MainModule;

function UniForm2: TUniForm2;
begin
 Result := TUniForm2(UniMainModule.GetFormInstance(TUniForm2));
end;

end.

Link to comment
Share on other sites

  • Administrators

Why do you call this?

 

 uniForm2.Refresh;

 

Refresh has no equivalent functionality in web mode.

 

 

 

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
 uniForm2.Refresh;
 uniEdit1.Text:=uniForm2.UniEdit1.Text;
 uniEdit2.Text:=uniForm2.UniEdit2.Text;
end;

 

Above code will not work if UniForm2 has been closed unless UniForm2.FreeOnClose is False.

 

Link to comment
Share on other sites

Why do you call this?

 

 uniForm2.Refresh;

 

Refresh has no equivalent functionality in web mode.

 

 

 

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
 uniForm2.Refresh;
 uniEdit1.Text:=uniForm2.UniEdit1.Text;
 uniEdit2.Text:=uniForm2.UniEdit2.Text;
end;

 

Above code will not work if UniForm2 has been closed unless UniForm2.FreeOnClose is False.

 

The original code had no uniForm2.Refresh command. Since it did not work properly so I try to play with it by adding some command like uniForm2.refresh to see if it may solve the problem.

 

I ran the code and click on button to open the second form. On the 2nd form have 2 uniEdit, I put some string on both uniEdits. Go back to the 1st Form and click on UniButton2, only sometimes it update the uniEdit1 and uniEdit2 on Form1. I don't know why. The version I use is 0.88.941.

Link to comment
Share on other sites

procedure TMainForm.UniButton2Click(Sender: TObject);
begin
 uniForm2.Refresh;
 uniEdit1.Text:=uniForm2.UniEdit1.Text;
 uniEdit2.Text:=uniForm2.UniEdit2.Text;
end;

If UniForm2->FreeOnClose is True and UniForm2 is closed above code will not work correctly.

 

Form2 still be opened. I just use the mouse click on form1 and click on the Unibutton2.

Link to comment
Share on other sites

OK. Please send a test case which can reproduce the issue.

 

I found something strange on my PC and Antivirus program show my PC was infected by some virus. Let me clean my PC and make sure it will not caused by virus. I will test it again and let you know after it was clean. Thank for your help.

Link to comment
Share on other sites

I found something strange on my PC and Antivirus program show my PC was infected by some virus. Let me clean my PC and make sure it will not caused by virus. I will test it again and let you know after it was clean. Thank for your help.

 

OK. My PC is cleaned. But the problem is still exist. I attached the program I made. I have 2 Forms , MainForm and uniForm1. Please run the program click on Open 2nForm button.

1. Try to put something on MainForm and use WriteDataToUniForm1 button, it works fine. whatever you change on the two uniEdit on mainform and click on WriteDataToUniForm1 button on mainform you will get the correct result on the uniForm1.

 

2. But if you change the data on Mainform and goto uniForm1 and click on ReadDataFromMainForm button, you will get the data update sometime, not everytime you click the button.

 

3. you can test it again by changing the data on the uniForm1 instead.

 

I don't know if this the bug or you intend to design it this way.

Project1.rar

Link to comment
Share on other sites

OK. My PC is cleaned. But the problem is still exist. I attached the program I made. I have 2 Forms , MainForm and uniForm1. Please run the program click on Open 2nForm button.

1. Try to put something on MainForm and use WriteDataToUniForm1 button, it works fine. whatever you change on the two uniEdit on mainform and click on WriteDataToUniForm1 button on mainform you will get the correct result on the uniForm1.

 

2. But if you change the data on Mainform and goto uniForm1 and click on ReadDataFromMainForm button, you will get the data update sometime, not everytime you click the button.

 

3. you can test it again by changing the data on the uniForm1 instead.

 

I don't know if this the bug or you intend to design it this way.

 

Hi Farshad

 

I sent my test file, Have you ever try my case? Please let me know what is wrong.

Link to comment
Share on other sites

  • 2 months later...

Issue logged #1282

 

Workaround:

 

Assign a dummy OnExit event to all Edit fields in both forms.

 

 

Can you explain further, or indicate if this is fixed. I would like to know how I can pass variable or contents of edit box values between many web forms that would be specific to each session. A public var does not seem to work for me, nor does the simple Delphi methods as shown in earlier posts of this thread.

 

John P.

Link to comment
Share on other sites

If this is fixed, do you have any realistic target when the next beta release may be ready for download. Are we looking at days, weeks, or more than a month for a timeline. Sorry, I need to do some planning.

 

John P.

 

Issue #1282 is fixed.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...