Jump to content
uniGUI Discussion Forums
Abaksoft

Using FreeForm

Recommended Posts

Hi,

 

Can you explain a little more what you wanted ?!

 

Best regards,

Share this post


Link to post
Share on other sites

You call the getText function, which creates the form, and on modalresult

then reads the public text property, which triggers the form's private getText

function, which reads the edit text and returns control to the app.

 

Interesting way of using a free form, indeed. I tested it and it works,

just remember to set the modalresult properties on the buttons...

Share this post


Link to post
Share on other sites

Thank you friends,

Yes DelphiDude, that is the purpose.

But, in build 1434, the freeForm is showing and the program continue... don't stop onShowModal.

Maybe i forgot a property setting !?

I will test and come back soon.

Thx.

Share this post


Link to post
Share on other sites

Hello  Friends,

 

I really block  !

 

@DD, any news about the testCase  ?

@DelphiDude, can you send here a zip of your test ?

 

Thank you in advance.

Share this post


Link to post
Share on other sites

Hi,

 

In this case you should use EnableSynchronousOperations = True

  • Upvote 1

Share this post


Link to post
Share on other sites

Hello Farshad,

As i don'nt like EnableSynchronousOperations,

I am trying to enable it at runtime when i need a freeform, and comeback to False after modalshow.

But this rise an exception :

"Blocking function showmodal..."

 

So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ?

Thx.

Share this post


Link to post
Share on other sites

So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ?

 

procedure TMainForm.UniButton2Click(Sender: TObject);
var Frm: TUniForm1;
begin
  Frm := TUniForm1.Create(UniApplication);
  Frm.ShowModal(
    procedure (Sender: TComponent; Res: Integer)
    begin
      if Res = mrOK then begin
        UniMemo1.Lines.Add(Frm.UniEdit1.Text);
      end else begin
        UniMemo1.Lines.Add('!Cancel!');
      end;
    end
  );
end;
  • Upvote 1

Share this post


Link to post
Share on other sites

Hello Farshad,

As i don'nt like EnableSynchronousOperations,

I am trying to enable it at runtime when i need a freeform, and comeback to False after modalshow.

But this rise an exception :

"Blocking function showmodal..."

 

So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ?

Thx.

 

Then you must use traditional callbacks which are recommended by default.

Share this post


Link to post
Share on other sites

Thank you Friends,

@Oliver : BRAVO very nice !

 

Best regards.

Share this post


Link to post
Share on other sites

Hello Oliver,

 

procedure TMainForm.UniButton2Click(Sender: TObject);
var Frm: TUniForm1;
begin
  Frm := TUniForm1.Create(UniApplication);
  Frm.ShowModal(
    procedure (Sender: TComponent; Res: Integer)
    begin
      if Res = mrOK then begin
        UniMemo1.Lines.Add(Frm.UniEdit1.Text);
      end else begin
        UniMemo1.Lines.Add('!Cancel!');
      end;
    end
  );
end;

 

Do we have to free the temporary  variable  Frm  ?

Where to put  :   Frm.Free   ?

Or is it automatically free  ?

 

Thx

Share this post


Link to post
Share on other sites

Do we have to free the temporary  variable  Frm  ?

Where to put  :   Frm.Free   ?

Or is it automatically free  ?

 

 

Set Form2.FreeOnClose to true; then it is automaticly freed. Otherwise you must use .Free in the callback procedure after doing your stuff.

  • Upvote 1

Share this post


Link to post
Share on other sites

Thank you very much Oliver,

I prefer the first method :

By default freeForm has FreeOnClose = True.

So, we don't care about memoryleak.

 

@Farshad, it's a high flying

i think, it's necessary to complete the online doc by all these important points.

Not obvious !

Thanks to all of you :)

Share this post


Link to post
Share on other sites

Hi,

 

The owner of the free form is not the global application, but the instance handling the current session.

Notice also that the form (frm) is automatically released (FreeOnClose is true and a value was assigned to ModalResult).

The variable itself will be released after going out-of-scope (when exiting the function GetText).

http://www.unigui.com/doc/online_help/free-form.htm

Share this post


Link to post
Share on other sites

Thank you DD,

Decidedly this topic is not over.

What sugest Oliver is not the same :

- on the online doc, variable frm is declared on the freeform. It's easy to understand that all will freed on closing the freeForm (FreeOnClose = True).

- on the code above (oliver) the frm is declared in a Mainform procedure. That why i couldn't understand the automatic free.

Thx again :)

 

Edited :

The code below don't use the online lightweight technic, but a classical way (frm.uniEdit.Text not the tip property Text sugested on online doc).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×