Bill Meyer 337 Posted December 1, 2021 I have a substantial collection of forms which may be changed from fsNormal to fsMDIChild at runtime. Not my doing, but my inheritance. Yes, it is wrong and should not be done. But I wonder whether there is a way to minimize the unpleasant artifacts.... The right way, I suppose, is to produce from each form a frame which contains the functionality, then create two forms, one fsNormal, the other fsMDIChild, as hosts for each of these frames. Eventually, I will go down that path, but still hope for a tolerable short-term approach. Share this post Link to post
Anders Melander 1783 Posted December 1, 2021 1 hour ago, Bill Meyer said: changed from fsNormal to fsMDIChild at runtime. ... Yes, it is wrong and should not be done. Why shouldn't it be done? I've previously worked on an application where the user, at run-time, could change between MDI and SDI if they wanted to (*). I had to do a few things to avoid flicker but apart from that it worked fine. *) Apparently some user gets confused by MDI and others by SDI. Share this post Link to post
Bill Meyer 337 Posted December 1, 2021 5 minutes ago, Anders Melander said: Why shouldn't it be done? First, I suppose because Delphi help warns against it. But based on observation, it seems to be responsible for the appearance of an empty form, followed later by the populated form, down and to the right from the empty one. Looks sloppy. Share this post Link to post
Anders Melander 1783 Posted December 1, 2021 Okay. But just so you know, it is possible to do without any visual artifacts - but you need to do few things to get it to work. Share this post Link to post
Bill Meyer 337 Posted December 1, 2021 3 minutes ago, Anders Melander said: Okay. But just so you know, it is possible to do without any visual artifacts - but you need to do few things to get it to work. That would be great. I have some two dozen forms which are affected in this way, and would prefer to keep things relatively simple. Share this post Link to post
Anders Melander 1783 Posted December 1, 2021 I'll see if I can find time to create a proof of concept for you tomorrow. Share this post Link to post
Bill Meyer 337 Posted December 1, 2021 5 minutes ago, Anders Melander said: I'll see if I can find time to create a proof of concept for you tomorrow. Much appreciated! Share this post Link to post
Anders Melander 1783 Posted December 3, 2021 Here you go. I've only included the stuff that directly deals with switching between SDI and MDI. The original code had a lot of logic related to positioning of the child windows, different layouts and and such. MDI_SDI.zip Share this post Link to post
Bill Meyer 337 Posted December 3, 2021 12 hours ago, Anders Melander said: Here you go. I've only included the stuff that directly deals with switching between SDI and MDI. The original code had a lot of logic related to positioning of the child windows, different layouts and and such. Thanks! Will be glad to resolve my misunderstandings of the issue. Curious, though, why the Delphi help recommends strongly against doing it. Share this post Link to post
Anders Melander 1783 Posted December 3, 2021 10 minutes ago, Bill Meyer said: Curious, though, why the Delphi help recommends strongly against doing it. Because the implementation wasn't designed to handle it. IMO there are better solutions. Docking for example (just not the VCL's docking - it's broken beyond repair). Share this post Link to post
yonojoy 2 Posted December 6, 2021 Change from fsNormal to fsMDIChild at runtime will lead to a recreation of the window handle, which might cause problems with some controls: https://stackoverflow.com/questions/14872063/why-is-it-not-advisable-to-change-the-formstyle-at-runtime/14872295 Share this post Link to post