cube18 Posted February 20, 2023 Share Posted February 20, 2023 Hi all, is it possible to call methods (or read/set properties values) contained in a form, without showing the form itself? For example: in my project there are 2 forms: Main and Unit1. Unit Main: //AllFeatures: Forms,Callback,icon-form-fieldui unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIRegClasses, uniguiclasses, uniGUIForm, uniMemo, uniGUIBaseClasses, uniButton; type TMainForm = class(TUniForm) UniMemo1: TUniMemo; btnTest1: TUniButton; bntTest2: TUniButton; procedure btnTest1Click(Sender: TObject); procedure bntTest2Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure ShowCallBack(Sender: TComponent; AResult:Integer); end; function MainForm: TMainForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication, Unit1; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; procedure TMainForm.bntTest2Click(Sender: TObject); begin //I'd like to call the function "UniForm1.Test" without UniForm1 shows UniMemo1.Lines.Add(UniForm1.Test); end; procedure TMainForm.btnTest1Click(Sender: TObject); begin //I'd like to set the "UniForm1.pMessage" value without UniForm1 shows UniForm1.pMessage:='TEST!'; end; initialization RegisterMainFormClass(TMainForm); end. Unit1: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIForm, uniGUIBaseClasses, uniButton, uniLabel; type TUniForm1 = class(TUniForm) UniButton1: TUniButton; UniButton2: TUniButton; UniLabel1: TUniLabel; private { Private declarations } public { Public declarations } pMessage: string; function Test: string; end; function UniForm1: TUniForm1; implementation {$R *.dfm} uses MainModule, uniGUIApplication; function UniForm1: TUniForm1; begin Result := TUniForm1(UniMainModule.GetFormInstance(TUniForm1)); end; function TUniForm1.Test: string; begin Result:='Hello world'; end; end. Is there any chance to execute btnTest1Click or btnTest2Click without the form Unit1 is displayed? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20, 2023 Share Posted February 20, 2023 Hello, First of all specify which edition and build of uniGUI are you using? Quote Link to comment Share on other sites More sharing options...
cube18 Posted February 20, 2023 Author Share Posted February 20, 2023 Hi, I'm using uniGUI Complete - Professional Edition v1.90.0.1564 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20, 2023 Share Posted February 20, 2023 Just now, cube18 said: Hi, I'm using uniGUI Complete - Professional Edition v1.90.0.1564 Please adjust your forum email address first: Quote Link to comment Share on other sites More sharing options...
cube18 Posted February 20, 2023 Author Share Posted February 20, 2023 4 minutes ago, Sherzod said: Please adjust your forum email address first: Done 👍 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20, 2023 Share Posted February 20, 2023 3 minutes ago, cube18 said: Done 👍 Thanks for the update. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 20, 2023 Share Posted February 20, 2023 53 minutes ago, cube18 said: Is there any chance to execute btnTest1Click or btnTest2Click without the form Unit1 is displayed? Well, a form must be shown after it is create. Referring to UniForm1 instances automatically creates it which means that it should be shown. You may need to use frames for such cases. 1 Quote Link to comment Share on other sites More sharing options...
cube18 Posted February 20, 2023 Author Share Posted February 20, 2023 Thanks for your support! I'll take a look to UniFrame, then. Thanks! Quote Link to comment Share on other sites More sharing options...
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.