I have an application that uses conditional expressions to be able to compile it either as a VCL Forms application or as a Windows service application in Delphi XE2. However, since I manually modified the main project file, the IDE will no longer allow me to make certain changes using the standard Project Settings window. In particular, I cannot select VCL Styles for inclusion or implementation.
Therefore, I need to implement VCL Styles manually. So, I added the two necessary modules Vcl.Themes and Vcl.Styles to my project initialization block (which in this case does NOT match the main project block) and essentially copied the code from the working application to this new application.
Here is the main block of the project:
program MyServiceApplication; uses uMyService in 'uMyService.pas' {MyService: TService}, uMyServiceMain in 'uMyServiceMain.pas', uMyServiceInit in 'uMyServiceInit.pas', uMyServiceTest in 'uMyServiceTest.pas' {frmMyServiceTest}; {$R *.RES} begin RunMyService; end.
And then in the project initialization block:
unit uMyServiceInit; interface uses {$IFDEF TESTAPP} Vcl.Forms, Vcl.Themes, Vcl.Styles, uMyServiceTest, {$ELSE} Vcl.SvcMgr, uMyService, {$ENDIF TESTAPP} uMyServiceMain ; procedure RunMyService; implementation procedure RunMyService; begin {$IFDEF TESTAPP} Application.Initialize; Application.MainFormOnTaskbar := True; TStyleManager.TrySetStyle('Carbon'); //<--- WILL NOT RUN - STYLE DOES NOT EXIST Application.Title := 'My Windows Service Application'; Application.CreateForm(TfrmMyServiceTest, frmMyServiceTest); {$ELSE} if not Application.DelayInitialize or Application.Installing then Application.Initialize; Application.CreateForm(TMyService, MyService); {$ENDIF TESTAPP} Application.Run; end; end.
The problem is that when I start the application, I get the error Style 'Carbon' could not be found. simply because this style was not included and compiled into the application.
How can I compile this style manually in this application so that VCL styles can implement it?
PS: The reason that initialization is in a separate module is because if the conventions were implemented inside the main block of the application, the IDE would destroy the code.
EDIT
One thing I tried: I opened the .dproj working project and searched for this carbon style, hoping to find some kind of configuration there, since the working project used this style, but no luck. The word does not exist anywhere in this file.