1

I have been asked for a way to update our application and add a VCL sytle to all of the components.

The application is made of many different programs (more than 200) so manually updating each one would be a long and tedious task.

So I would like to know if there is a way to update ALL of these projects so that each uses the same VCL style ? Right now, there is no styling applied at all.

Stephane
  • 3,173
  • 3
  • 29
  • 42
  • Work out what needs to be changed in the .dproj file, which is just an XML file. Then apply that change to all your .dproj files. A cuter way to go would be to apply common settings via an option set that you could reference from each project. Or perhaps it might be better to apply the changes in code, common code include in all your programs. Do be warned that VCL styles is buggy, and you will need to test all of your programs carefully. – David Heffernan Nov 08 '16 at 13:40
  • Thank you David. I was hoping there was a tool of procedure to perform that mass update without having to write one myself. Maybe you could put that in an answer. – Stephane Nov 08 '16 at 13:43
  • It's good to be able to write such tools. Learn a good scripting language such as Python and you can write such a tool in a few minutes. – David Heffernan Nov 08 '16 at 13:45
  • @DavidHeffernan The `.dpr` file needs to be updated with the code to actually apply the style... Even better, a resource DLL which is loaded by a common unit in each project, and applies the style that way. This is what our software does, and allows users to change their styles. Introducing a new style only needs to be added to this DLL, and it's instantly available in all projects which load it. – Jerry Dodge Nov 08 '16 at 14:43

1 Answers1

2

If you are planning add VCL Styles support to a large set of projects you have to build a custom tool or script, Try these options.

Option 1, embedding the VCL Style as a resource in the exe: Using this option you need to modify at least 2 files per project , the .dpr file which set the current VCL Style and the .dproj file which need a reference to the VCL Style file to embed the Style as a resource.

Option 2, using the VCL Style from a external file, Using this option you need to modify the .dpr file which set the current VCL Style adding the necessary code to load the style from an external file.

To modify the .dproj file you can use an automation tool or scripting language which supports XML.

For modify the .dpr file you need to build a custom Application ideally using a Delphi Parser like DelphiAST or Castalia-Delphi-Parser adding the necessary code to set the current VCL Style.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • There is an Option 3, as I hint in a comment in the Q - similar to Option 2, but when it comes to loading the file, there's a custom unit dedicated to the purpose of loading and applying the style. Simply add this unit to the uses clause anywhere in the project (preferably the .dpr file) and it takes care of the rest. The same unit can also embed the file as a resource. It would require utilizing the `initialization` section. – Jerry Dodge Nov 08 '16 at 15:09
  • Off course there many ways to implement the solution, but always will involve use a parser to _inject_ the new code. – RRUZ Nov 08 '16 at 15:13
  • Indeed, but this approach is flexible for future changes. Suppose, a year from now, OP wishes change it to a different style. Re-inject all that code, overwriting the prior code? Or make the change in this one unit and recompile? (Or replace the style file with one of the same name, but I wouldn't recommend it.) – Jerry Dodge Nov 08 '16 at 15:19