Home Different behavior of form resizing from Delphi 10.0 Seattle to 10.2.2 Tokyo
Reply: 2

Different behavior of form resizing from Delphi 10.0 Seattle to 10.2.2 Tokyo

Christine Ross
1#
Christine Ross Published in 2018-01-10 20:13:31Z

I installed the new Delphi 10.2.2 Tokyo and started to move my projects over to it.

I found the following strange behavior in a Windows desktop application.

I have a Form with a size of 700x545. To prevent the user from resizing it, I use the OnCanResize event and set the Resize parameter to False.

In the OnCreate event, I set the desired Width/Height values. With Delphi 10.0 Seattle, it works well, but in 10.2.2 the size is set to 340x220 instead.

Obviously, it is set before the OnCreate event, because my changes in the OnCreate event are ignored, maybe because of my OnCanResize event.

In design time, I find the correct values in the Object Inspector.

Any ideas?

Remy Lebeau
2#
Remy Lebeau Reply to 2018-01-10 20:26:17Z

When a Form object is created, its underlying window can (and usually is) created during DFM streaming, before the OnCreate event is fired. So, it is possible for the Form to want to perform resize operations before you are ready for them. This has always been a possibility in all versions of Delphi, it is not new behavior in Tokyo.

If you are going to use the Form's OnCanResize event, you should make sure the Form object is fully constructed and initialized before you start setting the event's Resize parameter to False. For instance, add a Boolean member to your Form class and set it to True in the OnCreate event, then have the OnCanResize event set the Resize parameter to the opposite value of that Boolean.

Alternatively, instead of using the OnCanResize event, consider using the Form's Contraints property instead, or simply set the Form's BorderStyle property to a non-resizable style, like bsSingle or bsDialog. Either way will allow you to resize the Form in code while preventing the user from resizing the Form manually.

Christine Ross
3#
Christine Ross Reply to 2018-01-11 18:48:22Z

Te difference between Seattle and 10.2.2 is following:

the oncanresize event is called twice before the oncreate event is called. The source comes from a TControl (i could not find out what control), the caller seems for me the ScaleforCurrentDPI procedure. In Seattle the oncanresize is never called before finishing the oncreate event.

For me it sounds like a bug when a onformdosomething event can be called before the oncreate event.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309155 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO