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 7757795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:11:10+00:00 2026-06-01T13:11:10+00:00

Possible Duplicate: How to switch an Application between Themed and not Themed at run-time?

  • 0

Possible Duplicate:
How to switch an Application between Themed and not Themed at run-time?

I create a GUI App with runtime themes option set to not enabled and need the option to manually enable an embedded Manifest during App initialization.

Question:

Does the VCL allow an extension point to implement that?

Let me explain:

  • The custom Manifest is embedded in the binary as a string constant.
  • Runtime themes is enabled using command line parameter switch, e.g.: MyApp.exe -themeOn

I have delved into Forms.TApplication in hope to find a handle but found nothing of interest pointing to a direction to go.

  • 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-01T13:11:12+00:00Added an answer on June 1, 2026 at 1:11 pm

    I would do this the other way around. I would include the standard comctl v6 manifest by enabling runtime themes in the project settings. Then I would call SetThemeAppProperties at startup, from the .dpr file, to disable runtime themes if necessary.

    procedure DisableRuntimeThemes;
    begin
      InitThemeLibrary;
      if Assigned(SetThemeAppProperties) then
        SetThemeAppProperties(STAP_ALLOW_NONCLIENT);
    end;
    
    begin
      if not FindCmdLineSwitch('themeOn') then
        DisableRuntimeThemes;
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TMainForm, MainForm);
      Application.Run;
    end.
    

    You’ll need to make sure that UxTheme is in the .dpr uses clause, or even better move that function to its own dedicated unit.

    It’s easier to include the manifest as normal and then disable runtime themes. The alternative of enabling runtime themes involves activation contexts which is rather more involved than this approach.


    Having said it was easier than using the activation context, I decided to see what was involved in that. And here’s what I came up with:

    unit ActivateRuntimeThemes;
    
    interface
    
    implementation
    
    uses
      Windows, SysUtils;
    
    type
      TActivationContext = class
      private
        FActCtxHandle: THandle;
        FCreateActCtx: function(var pActCtx: TActCtx): THandle; stdcall;
        FActivateActCtx: function(hActCtx: THandle; var lpCookie: LongWord): BOOL; stdcall;
        FDeactivateActCtx: function(dwFlags: DWORD; ulCookie: LongWord): BOOL; stdcall;
        FReleaseActCtx: procedure(hActCtx: THandle); stdcall;
        FCookie: LongWord;
        FSucceeded: Boolean;
      public
        constructor Create;
        destructor Destroy; override;
      end;
    
    constructor TActivationContext.Create;
    var
      ActCtx: TActCtx;
      hKernel32: HMODULE;
    begin
      inherited;
      hKernel32 := GetModuleHandle(kernel32);
      FCreateActCtx := GetProcAddress(hKernel32, 'CreateActCtxW');
      if Assigned(FCreateActCtx) then
      begin
        FReleaseActCtx := GetProcAddress(hKernel32, 'ReleaseActCtx');
        FActivateActCtx := GetProcAddress(hKernel32, 'ActivateActCtx');
        FDeactivateActCtx := GetProcAddress(hKernel32, 'DeactivateActCtx');
        ZeroMemory(@ActCtx, SizeOf(ActCtx));
        ActCtx.cbSize := SizeOf(ActCtx);
        ActCtx.lpSource := 'C:\desktop\comctlv6.manifest.txt';
        FActCtxHandle := FCreateActCtx(ActCtx);
        FSucceeded := (FActCtxHandle<>INVALID_HANDLE_VALUE) and FActivateActCtx(FActCtxHandle, FCookie);
      end
      else
        FActCtxHandle := INVALID_HANDLE_VALUE;
    end;
    
    destructor TActivationContext.Destroy;
    begin
      if FSucceeded then
        FDeactivateActCtx(0, FCookie);
      if FActCtxHandle<>INVALID_HANDLE_VALUE then
        FReleaseActCtx(FActCtxHandle);
      inherited;
    end;
    
    var
      ActivationContext: TActivationContext;
    
    procedure FinaliseActivationContext;
    begin
      ActivationContext.Free;
    end;
    
    initialization
      if FindCmdLineSwitch('themeOn') then
        ActivationContext := TActivationContext.Create;
    
    finalization
      ActivationContext.Free;
    
    end.
    

    You should include this unit as early as possible in your .dpr file. After any memory managers, but before any RTL/VCL units. Set runtime themes to None in the project settings. You’d probably want to include the manifest file as a resource, but I’ve done it as a file here for my convenience.

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

Sidebar

Related Questions

Possible Duplicate: How do I create a view that stays onscreen while I switch
Possible Duplicate: How to switch between visible buffers in emacs? I'm using C-x 2
Possible Duplicate: Javascript switch vs. if…else if…else just curious if things will run faster
Possible Duplicate: C# - Is there a better alternative than this to ‘switch on
Possible Duplicate: Django switching, for a block of code, switch the language so translations
Possible Duplicate: is “else if” faster than “switch() case” ? I've encountered a lot
Possible Duplicate: Switch Case on type of object (C#) I have a method signature
Possible Duplicate: Drag and Drop Java GUI Hi about 3 months ago I started
Possible Duplicate: Switch statement fallthrough in C#? The following code is illegal in C#
Possible Duplicate: Multiple Cases in Switch: Is it possible to do a multiple constant-expression

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.