Jump to content
Bill Meyer

FormStyle in legacy code

Recommended Posts

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

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.

image.thumb.png.c55c62d165abc2b18c3850a35cd4eb00.pngimage.thumb.png.c52325f6c0d3d372ed706320265d2482.png

MDI_SDI.zip

Share this post


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

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

×