Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:54:37+00:00 2026-06-11T20:54:37+00:00

I have an application which uses conditionals to be able to compile it either

  • 0

I have an application which uses conditionals to be able to compile it either as a VCL Forms Application or as a Windows Service Application in Delphi XE2. However, since I have manually altered the project’s main source file, the IDE will no longer allow me to make certain modifications using the standard Project Options window. Specifically, I am not able to select VCL Styles to include or implement.

Therefore, I have to implement VCL Styles manually. So, I added the two necessary units Vcl.Themes and Vcl.Styles to my project’s initialization unit (which in this case is NOT the same as the project’s main unit), and essentially copied the code from a working application into this new application.

Here’s the project’s main unit:

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’s initialization unit:

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 trouble is, when the application runs, I get an error Style 'Carbon' could not be found. simply because this style has not been included and compiled into the application.

How can I compile this style manually into this application so that the VCL Styles can implement it?

PS: The reason why the initialization is in a separate unit is because if the conditionals were implemented inside the application’s main unit, the IDE would destroy the code.

EDIT

One thing I have tried: I opened a working project’s .dproj file and searched for this style carbon hoping to find some configuration for it there, since the working project used this style, but with no luck. The word does not exist anywhere in that file.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:54:38+00:00Added an answer on June 11, 2026 at 8:54 pm

    TStyleManager is loading available styles from a ‘VCLSTYLE’ resource section of the executable (unless you set TStyleManager.AutoDiscoverStyleResources to false). The resource is what’s missing in your scenario.
    Basically, there are three ways to add your style as a resource in the exe.

    • Through the ‘Project’ -> ‘Resources and Images..’ menu. Add the style clicking the ‘Add’ button in the dialog, set its type to ‘VCLSTYLE’ and identifier to ‘CARBON’.

    • As Ken mentioned in the comment to the question, through an .rc file. This is a text file which can contain a line per style (and/or other resources). Like

      CARBON VCLSTYLE "C:\..\RAD Studio\9.0\Redist\Styles\Vcl\Carbon.vsf"


      (you can use relative paths if it is feasible). Let's name the file 'styles.rc', add the file to the project through project manager (or use brcc32.exe in the bin folder to compile it to a .res file) and then add a {$R styles.res} line to your unit.

    • As RRUZ told in his answer that he linked in a comment to the question, by editing the .dproj file. Under the <PropertyGroup Condition="'$(Base)'!=''"> key, add a VCL_Custom_Styles entry (his example includes several styles):

      <VCL_Custom_Styles>&quot;Amakrits|VCLSTYLE|$(PUBLIC)\Documents\RAD Studio\9.0\Styles\Amakrits.vsf&quot;;&quot;Amethyst Kamri|VCLSTYLE|$(PUBLIC)\Documents\RAD Studio\9.0\Styles\AmethystKamri.vsf&quot;;&quot;Aqua Graphite|VCLSTYLE|$(PUBLIC)\Documents\RAD Studio\9.0\Styles\AquaGraphite.vsf&quot;</VCL_Custom_Styles>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Delphi 7 on Windows 7 and have an application which uses
I have an IOS application which uses environment variables and am able to set
I'm building a windows service application which has a configuration to compile it as
I have an application which uses a web service to get data. Before getting
I have an application which uses a custom title bar. However, when my application
I have an application which uses 2 forms, a Main Form and a Splash
I have one application which uses the standard .NET forms authentication cookie, now I
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for
I have an application which uses the microsoft kinect device. The thing is that
I have an application which uses code that produces various types of objects and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.