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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:32:39+00:00 2026-06-01T20:32:39+00:00

I’m trying to create a form with a user selected style saved to an

  • 0

I’m trying to create a form with a user selected style saved to an ini file (JvFormStorage and JVIniFileStorage). The problem I have is if I put my code in the OnCreate it doesn’t work, In the OnShow works but I get the error:

“Cannot change Visible in OnShow or OnHide”

even if this is the only code in the OnShow or in a procedure call (Green1 a MenuItem but will convert to combobox choices) I.e.:

Procedure TForm1.ChangeTheme;
begin
if Assigned(TStyleManager.ActiveStyle) then Begin
 If (Green1.Checked) and (TStyleManager.ActiveStyle.Name<>'Light Green') then
  TStyleManager.TrySetStyle('Light Green') else
 ... else
 TStyleManager.TrySetStyle(fdefaultStyleName);
end;

Also tried:

    Application.Initialize;
    Application.CreateForm(TForm1, Form1);
    Form1.ChangeTheme;
    Form1.Show;
    Application.Run;

Does work but does flicker from normal windows to ‘styled’ and would prefer no flicker if possible.

I may well be going around this completely the wrong way.
Thanks Paul

  • 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-01T20:32:40+00:00Added an answer on June 1, 2026 at 8:32 pm

    In your case the OnCreate event is the proper place to load the vcl style.

    This is a minimal sample working application, (the application must include the “carbon” and “auric” styles)

    Project Code

    program Project2;
    
    uses
      Vcl.Forms,
      Unit1 in 'Unit1.pas' {Form1};
    
    {$R *.res}
    
    begin
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    end.
    

    Form Code

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        Green1: TCheckBox;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    uses
     Vcl.Styles,//including this unit init the vcl styles services.
     Vcl.Themes;
    
    {$R *.dfm}
    
    procedure TForm1.FormCreate(Sender: TObject);
    var
     fdefaultStyleName : string;
    begin
     fdefaultStyleName:='Auric';
     if StyleServices.Enabled then
       If (Green1.Checked) and (not SameText(TStyleManager.ActiveStyle.Name,'Carbon')) then
        TStyleManager.TrySetStyle('Carbon')
       else
       TStyleManager.TrySetStyle(fdefaultStyleName);
    end;
    

    dfm

    object Form1: TForm1
      Left = 520
      Top = 299
      Caption = 'Form1'
      ClientHeight = 294
      ClientWidth = 534
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      OnCreate = FormCreate
      PixelsPerInch = 96
      TextHeight = 13
      object Button1: TButton
        Left = 32
        Top = 256
        Width = 75
        Height = 25
        Caption = 'Button1'
        TabOrder = 0
      end
      object Green1: TCheckBox
        Left = 32
        Top = 56
        Width = 97
        Height = 17
        Caption = 'Green1'
        TabOrder = 1
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a reasonable size flat file database of text documents mostly saved in
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.