0

I'm tired of writing the same code over and over; I'd like to create a (main) form with components, code, etc. that will become part of every application I create. (Think visual form inheritance.) ... What features would you include?

I like my forms to save their position and size via config files, for example, so I'll include that feature. I'll probably also include the ability for the form to go full screen with the F11 key.

What else do you include?

Al C
  • 5,175
  • 6
  • 44
  • 74
  • 2
    This kind of depends on the type of application, doesn't it? – Andreas Rejbrand Mar 08 '12 at 06:09
  • For future diagnostics of potential performance issues, I would add form creation time statistics collection (which can be enabled when needed) - see http://stackoverflow.com/questions/2442127/how-can-a-delphi-tform-tpersistent-object-calculate-its-own-construction-and-d – mjn Mar 08 '12 at 07:08
  • I have a base class that I use that stores the forms position and size in the registry – Nat Mar 08 '12 at 07:47
  • 1
    I sounds like you are making a template form. try using the repository it may not be perfect like you wanted but it helps you a lot. or you can place it in the TFrame so you can drag n drop and inherit some of your code. – XBasic3000 Mar 08 '12 at 08:31
  • I add a security/permission procedure. When some user login on the application. The layout and action are changed for the user. Like permission to save or change something on the form or some tabs are not visible for this user. – Ravaut123 Mar 08 '12 at 08:58
  • I understand the close votes: this never results in one best fitting answer. But I surely would like to know all of them! – NGLN Mar 08 '12 at 11:55
  • 1
    @NGLN: Then this question should probably be made community wiki. – Andriy M Mar 08 '12 at 23:34

2 Answers2

2

Set AutoScroll = False to force Delphi to store the client size (rather then the bound size) of a form to the DFM, in order to get the same client form dimensions on different operating systems.

And to quote Ian Boyd from that same post:

Since i try to be a good developer, i make my form's respect the user's font preference. During the OnCreate of all my forms i call a StandardizeForm(Self) function that:

  • scales the form to match the user's default font size
  • changes the font on all controls on the form to the user's preference
  • issues an ODS if the form is set mistakenly set to Scaled
  • issues an ODS and breakpoint if AutoScroll false (and sets it to true)
  • issues an ODS and breakpoint if ShowHint is false (and turns it on)
  • etc
Community
  • 1
  • 1
NGLN
  • 43,011
  • 8
  • 105
  • 200
0

I had a Delphi framework that went through a few incarnations from D5-D2007... I think I had a 2007 version. I did have both SDI/MDI versions of the thing... and here's a short list of features.

The main form had a datasource property used for all data navigation and interaction. All the standard menu items (Edt: cut, copy; File: close, ext; Help: etc..) There was a "main" data module that had an abstract user object for login... a descendant data module was used for specific database types, MQSQL, IB, etc. The main datamodule had a "PrepareDataset" method that was generic, the descendant would then setup each dataset type with the right connection object.

I also had a generic "maintenance form", this was used to edit all the basic lookup tables with a grid on a form, like "PhoneNumberTypes" or "States".

The factory of the framework did the following... - The main form contained a virtual factory for child forms. - Each form had to make a "FormFactory.RegisterForm" call in it's initialization of the unit. - The registration call included a path, priv, caption parameters - Path: (i.e. 'File\Open\Contacts') the main form creates a menu item in that location - Caption: The caption of the menu item - Priv: (i.e. 'TContanctForm') the factory checks it against the user to allow the form's creation.

...well the list goes on... but it was really nice. I think the best part about its design was that each developer was able to develop a "form" without ever needing or having the latest framework code. As long as they made the registration call, and descendant from the TFrameWorkChild form... it all just worked.

GDF
  • 830
  • 5
  • 11