Clipe Informática Posted February 5, 2021 Share Posted February 5, 2021 I have a situation where i create a form in background to use some methods from it. At some point i use the "UniSession.Synchronize" method and the form that i created in background is now beening shown at the screen. Why this happens? How can i avoid it? Here is the code: var vSF0270 : TSF0270; begin inherited; vSF0270 := TSF0270.Create(UniApplication); vSF0270.x:= 'bla bla bla'; UniSession.Synchronize; showmessage(vSF0270.x); I'm using the professional version. Link to comment Share on other sites More sharing options...
rgreat Posted February 5, 2021 Share Posted February 5, 2021 UniGUI forms are shown right after they are created. That's normal. Do not create form or call Close before Synchronize, if you do not want it to be shown. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted February 6, 2021 Share Posted February 6, 2021 6 hours ago, Clipe Informática said: I have a situation where i create a form in background to use some methods from it. At some point i use the "UniSession.Synchronize" method and the form that i created in background is now beening shown at the screen. Why this happens? How can i avoid it? Here is the code: var vSF0270 : TSF0270; begin inherited; vSF0270 := TSF0270.Create(UniApplication); vSF0270.x:= 'bla bla bla'; UniSession.Synchronize; showmessage(vSF0270.x); I'm using the professional version. Do you want to show that form later or you will destroy it when you finish? 1 Link to comment Share on other sites More sharing options...
Clipe Informática Posted February 6, 2021 Author Share Posted February 6, 2021 I will destroy it right after i finish. Link to comment Share on other sites More sharing options...
Clipe Informática Posted February 10, 2021 Author Share Posted February 10, 2021 On 2/5/2021 at 5:29 PM, rgreat said: UniGUI forms are shown right after they are created. That's normal. You see, I´m migrating and old delphi application to uniGUI. On that app was normal to create a form just to call a function/procedure from it and then destroy it. I know its not the perfect/ideal way to do this, but it´s how was done. Now the problem is that i need to show some logs on the screen during the process, and for that i need to use "UniSession.Synchronize;" Only when the synchronize is called the form that was created in background is showen. There should be a way to create a form, use its methods/variables and destroy it without showing it in the process, even if i use "UniSession.Synchronize;" Does this already exists? Am i missing something? Link to comment Share on other sites More sharing options...
rgreat Posted February 11, 2021 Share Posted February 11, 2021 14 hours ago, Clipe Informática said: There should be a way to create a form, use its methods/variables and destroy it without showing it in the process, even if i use "UniSession.Synchronize;" Just call vSF0270.Close; before UniSession.Synchronize; Form will not be shown. Maybe you should also set vSF0270.FreeOnClose:=False, if you want to work with form properties later. Link to comment Share on other sites More sharing options...
Clipe Informática Posted February 11, 2021 Author Share Posted February 11, 2021 I tried as you said, but it doesn't work as you said. Here is what happens: var vSF0270 : TSF0270; begin inherited; vSF0270 := TSF0270.Create(UniApplication); UniSession.Synchronize; //<- the form is shown vSF0270.Close; //<- this does not hides the form vSF0270.x:= 'bla bla bla'; UniSession.Synchronize; //<- the form is still being shown sleep(5000); vSF0270.x:= vSF0270.x + 'x'; UniSession.Synchronize; showmessage(vSF0270.x); //<- the form is still being shown behind the message freeandnil(vSF0270); //<- only here the form disappears The form is only shown when I call "UniSession.Synchronize" and it keeps there until i call the freeandnil function. Link to comment Share on other sites More sharing options...
rgreat Posted February 11, 2021 Share Posted February 11, 2021 Yep. I checked it is not working now. Still you could call Close; in form OnShow event. Something like: procedure TUniForm1.UniFormShow(Sender: TObject); begin if CreateNonVisual then Close; end; That will do the trick. That's quite a dirty way to do things, though. I wish Farshad will change this behavior at least for free forms. Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted February 12, 2021 Share Posted February 12, 2021 Hi Assing parent:= nil. Form will not be shown. 1 Link to comment Share on other sites More sharing options...
Clipe Informática Posted February 15, 2021 Author Share Posted February 15, 2021 FYI, i tried your suggestion and still the form is shown. That's how i made it: var vSF0270 : TSF0270; begin inherited; vSF0270 := TSF0270.Create(UniApplication); vSF0270.Parent:= Nil; UniSession.Synchronize; //<- the form is shown vSF0270.Close; //<- this does not hides the form vSF0270.x:= 'bla bla bla'; UniSession.Synchronize; //<- the form is still being shown sleep(5000); vSF0270.x:= vSF0270.x + 'x'; UniSession.Synchronize; showmessage(vSF0270.x); //<- the form is still being shown behind the message freeandnil(vSF0270); //<- only here the form disappears Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted February 16, 2021 Share Posted February 16, 2021 Hi, You right. i checked and mine is TUniFrame. Link to comment Share on other sites More sharing options...
Sherzod Posted February 16, 2021 Share Posted February 16, 2021 On 2/15/2021 at 5:49 PM, Clipe Informática said: FYI, i tried your suggestion and still the form is shown. That's how i made it Hello, You can adapt this code to your needs: function window.show(sender, eOpts) { this.setHidden(true); } Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now