Question

Every time I add a new form to my project, it drops a big glop of boilerplate in the uses clause.

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

Seriously, who uses the Variants unit on anything resembling a regular basis? I generally end up removing Windows, Messages, Variants, Graphics and Dialogs and never missing them.

That's gotta be coming out of a template file somewhere, but I can't seem to find it. Does anyone know where I can find the template and edit it? I'm using D2009, in case it's changed recently.

Was it helpful?

Solution

The according resource is located in $(BDS)\bin\delphivclide*.bpl and named "VCLIDECMD"; you can extract, edit and update it with the resource editor of your choice (I recommend the one included in Pelles C).

For C++Builder users, the template file is "CPPVCLIDECMD" in bcbvclide*.bpl.

If you are using a localized version of RAD Studio, look at the appropriate language resource files (*.DE, *.FR or *.JA).

OTHER TIPS

You are not saving anything by removing Windows and Messages. Graphics and Dialogs may get added back in based on what components you drop on the form, and they are fairly useful to reference anyway. Doubt you are saving much by removing them. Feel free to remove variants if you are not using them (which I agree is pretty common unless doing COM or DB development).

I guess it all depends on your objective in cleaning the uses clause. Variants is really the only one that may have an impact on your application.

As far as changing the default template, I believe it is in a package that says if you are descending from a TForm then you get those. You would most likely need to modify a .PAS file and rebuild the VCL packages. A lot of work for very little gain.

I usually use "Uses cleaner" which is coming with cnPack after finishing the project, it will give you a list for all unused units in your project, because usually when finishing project you may have larger unused units than you mentioned.

Actually, that bothered me aswell.

But then i checked the executable size compiled with the default units and then checked it without them (Messages, Variants, Grahpics) and the size was not much smaller.

Dialogs.pas adds some kilobytes, but I frequently use delphi VCL dialogs over Win API ones.

So, I'd say not bother too much with them

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top