How do I reduce “uses” boilerplate for new forms?

后端 未结 4 600
梦毁少年i
梦毁少年i 2021-01-11 16:31

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


        
相关标签:
4条回答
  • 2021-01-11 17:03

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

    0 讨论(0)
  • 2021-01-11 17:15

    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.

    0 讨论(0)
  • 2021-01-11 17:20

    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

    0 讨论(0)
  • 2021-01-11 17:21

    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.

    0 讨论(0)
提交回复
热议问题