Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Modal form does not inherit design settings



Permlink Replies: 10 - Last Post: Nov 21, 2016 1:19 PM Last Post By: Markus Humm
Shanil M

Posts: 62
Registered: 12/24/04
Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 4:51 AM
Hi I am using Delphi 10.1 Berlin Version 24.0.25048.9432 update 2.

As usual I am struggling with every component in android, whereas in Windows it just works.

I have a form2 which is 'available' in options and has design components such as toolbars, comboboxes and date/time pickers. It has defined height/width and is position screencenter because I want this form to pop up modally and then return result to main form1.

I am using the recommended method for modal forms in android:
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_FireMonkey_Modal_Dialog_Boxes

In windows it works as expected. In android it pops up full screen, and I assume it did not inherit some settings. Why? It shows all the components, but I don't want it full screen. Even if I can force it to use designed height and width I will be happy.

This is the code in form1.

  fmreminder.form2 := tform2.create(self);
  fmreminder.form2.ShowModal(
    procedure(ModalResult : TModalResult)
    begin
      if ModalResult = mrOK then
        showmessage(xrdate+' '+xrtime);         
    end);
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 2:16 PM   in response to: Shanil M in response to: Shanil M
Am 18.11.2016 um 13:51 schrieb Shanil M:
Hi I am using Delphi 10.1 Berlin Version 24.0.25048.9432 update 2.

As usual I am struggling with every component in android, whereas in Windows it just works.

I have a form2 which is 'available' in options and has design components such as toolbars, comboboxes and date/time pickers. It has defined height/width and is position screencenter because I want this form to pop up modally and then return result to main form1.

I am using the recommended method for modal forms in android:
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_FireMonkey_Modal_Dialog_Boxes

In windows it works as expected. In android it pops up full screen, and I assume it did not inherit some settings. Why? It shows all the components, but I don't want it full screen. Even if I can force it to use designed height and width I will be happy.

This is the code in form1.

  fmreminder.form2 := tform2.create(self);
  fmreminder.form2.ShowModal(
    procedure(ModalResult : TModalResult)
    begin
      if ModalResult = mrOK then
        showmessage(xrdate+' '+xrtime);         
    end);


Hm? Afaik .ShowModal is not suppoed to work in Android, as Android
doesn't want to you have any modal forms!

What you can do is to have some panel or similiar which is on top of
everything and contains your form2's contents and is usually invisible.

I gues you could even design a TFrame to better separate the stuf and
just create this at runtime making that usually invisible panel the
owner/parend. But bear in mind that for yet unknown reasons the ability
to show the controls you place on the TFrame in form designer can no
longer be placed there in "Android style" so you only see at runtime how
it will really look (or maybe in LivePreview or how it's called).

You might want to vote for this one:

https://quality.embarcadero.com/browse/RSP-10423

Greetings

Markus
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 4:04 PM   in response to: Markus Humm in response to: Markus Humm
Markus wrote:

Hm? Afaik .ShowModal is not suppoed to work in Android, as
Android doesn't want to you have any modal forms!

Yes, and this is clearly stated in the ShowModal() documentation:

http://docwiki.embarcadero.com/Libraries/en/FMX.Forms.TCommonCustomForm.ShowModal

Caution: Modal dialog boxes are not supported in Android apps. Instead of
calling ShowModal, you should call Show, and have the form return and call
your event. We recommend do not use modal dialog boxes on either of the mobile
platforms (iOS and Android) because unexpected behavior can result. Avoiding
usage of modal dialog boxes eliminates potential problems in debugging and
supporting your mobile apps.

--
Remy Lebeau (TeamB)
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 4:11 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Yes, and this is clearly stated in the ShowModal() documentation:

The warning appears to be out-dated, as the overloaded method works on Android. At least, I'm yet to encounter any
issues with it :-)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Shanil M

Posts: 62
Registered: 12/24/04
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 12:48 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
moving reply to bottom...

Edited by: Shanil M on Nov 21, 2016 1:09 AM
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 18, 2016 4:06 PM   in response to: Markus Humm in response to: Markus Humm
Markus Humm wrote:

Hm? Afaik .ShowModal is not suppoed to work in Android, as Android
doesn't want to you have any modal forms!

The ShowModal method overload that accepts an anonymous method as a parameter works on Android. The anonymous method is
what is called once the window is closed.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Shanil M

Posts: 62
Registered: 12/24/04
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 1:10 AM   in response to: Dave Nottage in response to: Dave Nottage
Hi

If ShowModal is not supported (and yes I had seen this note previously), then why is this method published?
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_FireMonkey_Modal_Dialog_Boxes
Also it does work modally, but then I end up with the problem of fullscreen and properties not inherited as described in my post.

Also it's interesting you talk about using panels or frames instead of modal forms.
What then of programming with taking limited mobile memory into account?
Is it better to put many invisible panels onto the main form, or to have 'available' forms that can be opened at run-time and freed?
Once my project is ready, I want to reduce its memory footprint as well as distributable size, which at the moment is way too large.

thanks
Shanil
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 2:04 AM   in response to: Shanil M in response to: Shanil M
Shanil M wrote:

Also it's interesting you talk about using panels or frames instead of modal forms.
What then of programming with taking limited mobile memory into account?
Is it better to put many invisible panels onto the main form, or to have 'available' forms that can be opened at
run-time and freed?

One technique is to have a frame be shown completely over the top of the main form.

If the part of the "modal" form that the user interacts with is smaller than the main form, that part could also be in
a frame, and would be inside of the outer frame, which is made transparent (or possibly semi-transparent), but the
HitTest on the outer frame is set to True, thus preventing the user from interacting with the form underneath it.

These frames can be created and destroyed at runtime if memory usage is a concern.

It's probably better to refer to an example rather than go into a detailed explanation here. It's about time I posted
again in my blog, and this is a likely candidate.

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Shanil M

Posts: 62
Registered: 12/24/04
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 2:25 AM   in response to: Dave Nottage in response to: Dave Nottage
Dave Nottage wrote:
One technique is to have a frame be shown completely over the top of the main form.

I'm a bit worried to use frames given what Markus said above. So far the panels work as expected on android. It seems a lot of new components are buggy and have a 'keep off the grass' signpost on them for the time being. It's a concern, given the price of Berlin and every new 'major' version that comes at (almost) full price.

Nice idea on the hittest though :)

Thanks!
Dave Nottage

Posts: 1,850
Registered: 1/7/00
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 2:56 AM   in response to: Shanil M in response to: Shanil M
Shanil M wrote:

I'm a bit worried to use frames given what Markus said above.

The usual problems with frames happen when you add them to a form (or another frame) at design-time. The solution is to
do that at run time :-)

--
Dave Nottage [MVP, TeamB]
Hints, tips and tricks at: http://www.delphiworlds.com/blog
Markus Humm

Posts: 5,113
Registered: 11/9/03
Re: Modal form does not inherit design settings
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 21, 2016 1:19 PM   in response to: Shanil M in response to: Shanil M
Am 21.11.2016 um 10:10 schrieb Shanil M:
Hi

If ShowModal is not supported (and yes I had seen this note previously), then why is this method published?

Because it can be used on the desktop platforms?
Remember: FMX is not about mobile alone ;-)

Greetings

Markus
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02