Jump to content

Using FreeForm


Abaksoft

Recommended Posts

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...

Link to comment
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.

Link to comment
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
Link to comment
Share on other sites

  • Administrators

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.

Link to comment
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

Link to comment
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 :)

Link to comment
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

Link to comment
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).

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...