Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Form Design - Should I use frames?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Oct 1, 2016 7:57 AM Last Post By: Roy Lambert
Toby Dobbs

Posts: 77
Registered: 9/24/16
Form Design - Should I use frames?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 4:11 AM
Hi,

I have been developing an application with several UIs, currently represented by several forms. I would like to adjust this so that all UIs appear within the same form depending on the user's actions. One way that I can think of doing this is through the use of frames which I can show or hide accordingly - I do however imagine that there is probably a better way so suggestions would be appreciated.

Regards
Enquiring Mind

Posts: 88
Registered: 10/6/08
Re: Form Design - Should I use frames?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 5:43 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby Dobbs wrote:
Hi,

I have been developing an application with several UIs, currently represented by several forms. I would like to adjust this so that all UIs appear within the same form depending on the user's actions. One way that I can think of doing this is through the use of frames which I can show or hide accordingly - I do however imagine that there is probably a better way so suggestions would be appreciated.

Regards

Hi,

If you want a secondary form to be in existence all the time in the main form, then you can convert it to into a frame, and drop the frame where you need it onto a parent component such as a TPanel in the main form. If, on the other hand, you want to be able release the memory of the secondary form when it's not in use, you can convert it to a child form. A TChildForm class can be derived from the TForm class. This derived class would specialise TForm by automatically set a few properties such as Params.Style, Align, BorderStyle, BorderIcons, Parent, and Position appropriately. The child form can be instantiated when needed and displayed in a parent component on the main form, such as a panel or tabsheet, by setting its Parent property at runtime. The child form will appear to the user like an integral part of the main form. It is possible to allow the user to undock the child form from the main form and revert it to a free floating form by providing an action which changes to the properties mentioned above back to values appropriate to a normal floating form. If you want to see some code for implementing a child form, look in the Delphi Developer's Guide series.

Word of warning: this is my experience based on using old versions of Delphi. There may well be better ways of doing this in the current version of Delphi.

Regards,
EM
Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: Form Design - Should I use frames?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 7:12 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby

It depends on the visual impression you want to create. I tend to use a pagecontrol and forms. Parent the form to the appropriate page and use show - not showmodal. Personally I find frames a pain to work with and forms are much better. Using forms you also have the option of using them as forms again with (probably) zero code changes.

The one disadvantage is that you can't see the visual impact at design time which you can do with frames.

Roy Lambert

Clement Doss

Posts: 133
Registered: 9/19/00
Re: Form Design - Should I use frames?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 9:41 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Hi,

IMO this is more related with the architectural aspects of your application. In my case I'm using Frames.
In my entire application I have 2 or 3 forms, but tons of frames. The frames are docked at runtime.
There's no performance penalty.
The handling code is in the base form classes, and the UI code is in the Frame base classes.
The same way you can combine Forms in several TabSheets, you also can do the same with frames.

But take a look at the Frame class definition:
  TCustomFrame = class(TScrollingWinControl)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    procedure PaintWindow(DC: HDC); override;
    procedure SetParent(AParent: TWinControl); override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  end;
 
  TCustomFrameClass = class of TCustomFrame;
 
  TFrame = class(TCustomFrame)
  ..
 ..

TCustomForm class has over 400 lines of properties, methods and fields. That's expected since forms must handle many more things.
I'd expect many forms docked on a form to be heavier than many frames docked on a form. That should be true in large applications.

Anyway, my 0.02c
Clément

Roy Lambert

Posts: 1,063
Registered: 8/7/01
Re: Form Design - Should I use frames? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 1, 2016 7:57 AM   in response to: Clement Doss in response to: Clement Doss
Clement

I'd expect some difference but I also expect the code to be shared so it shouldn't be that massive a difference.

Roy Lambert

Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Form Design - Should I use frames?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 30, 2016 9:43 AM   in response to: Toby Dobbs in response to: Toby Dobbs
Toby Dobbs wrote:

Hi,

I have been developing an application with several UIs, currently
represented by several forms. I would like to adjust this so that all
UIs appear within the same form depending on the user's actions. One
way that I can think of doing this is through the use of frames which
I can show or hide accordingly

That is the design I currently use in the majority of my applications.
The frames are not dropped on the (main) form at design-time, though. I
create them in code and parent them to a panel acting as container on
the form when the user first selects an action that is served by the
frame. The frames stay in in existence until the application ends once
they have been created.

--
Peter Below
TeamB
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02