AMIT Posted February 27, 2012 Posted February 27, 2012 How to pass the data such as string, integer, double, ... between form? For example, I want to set the value of uniEdit of Form2 before I show it and when I close Form2 I need to have some value return to Form1. Quote
Administrators Farshad Mohajeri Posted February 27, 2012 Administrators Posted February 27, 2012 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. Quote
AMIT Posted February 27, 2012 Author Posted February 27, 2012 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. Quote
Administrators Farshad Mohajeri Posted February 27, 2012 Administrators Posted February 27, 2012 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. Quote
AMIT Posted February 27, 2012 Author Posted February 27, 2012 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. Quote
Administrators Farshad Mohajeri Posted February 27, 2012 Administrators Posted February 27, 2012 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. Quote
AMIT Posted February 27, 2012 Author Posted February 27, 2012 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. Quote
Administrators Farshad Mohajeri Posted February 27, 2012 Administrators Posted February 27, 2012 Form2 still be opened. I just use the mouse click on form1 and click on the Unibutton2. OK. Please send a test case which can reproduce the issue. Quote
AMIT Posted February 27, 2012 Author Posted February 27, 2012 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. Quote
AMIT Posted February 29, 2012 Author Posted February 29, 2012 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 Quote
AMIT Posted February 29, 2012 Author Posted February 29, 2012 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. Quote
Administrators Farshad Mohajeri Posted February 29, 2012 Administrators Posted February 29, 2012 Not yet. I'll inform you when I test it. Quote
AMIT Posted February 29, 2012 Author Posted February 29, 2012 Not yet. I'll inform you when I test it. Thank you for your help. Quote
Administrators Farshad Mohajeri Posted February 29, 2012 Administrators Posted February 29, 2012 Issue logged #1282 Workaround: Assign a dummy OnExit event to all Edit fields in both forms. Quote
johnp Posted May 25, 2012 Posted May 25, 2012 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. Quote
Administrators Farshad Mohajeri Posted May 25, 2012 Administrators Posted May 25, 2012 Issue #1282 is fixed. Quote
johnp Posted May 29, 2012 Posted May 29, 2012 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. Quote
Administrators Farshad Mohajeri Posted May 29, 2012 Administrators Posted May 29, 2012 This fix is available in latest beta build. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.