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

  • SEARCH
  • Home
  • 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 3437066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:01:11+00:00 2026-05-18T08:01:11+00:00

I am using Delphi 2010 to build a Win32 GUI application running on Windows

  • 0

I am using Delphi 2010 to build a Win32 GUI application running on Windows XP/Vista and Windows 7.

Basically, the Application.MainForm is a read only property and can’t be changed at runtime once the first form is created via Application.CreateForm:

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.

The above example will make Form1 as application’s mainform. It will show on Windows 7 taskbar’s thumbnail preview.

Setting Application.MainFormOnTaskBar to true at runtime allow us to enjoy Windows aero theme features.

I need to switch the application’s mainform at runtime. For example, set Form2 as main form. I use following code to make it work:

procedure SetAsMainForm(aForm:TForm);
var
  P:Pointer;
begin
  Application.MainFormOnTaskBar := False;
  try
    P := @Application.Mainform;
    Pointer(P^) := aForm;
    aForm.Show;
  finally
    Application.MainFormOnTaskBar := True;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SetAsMainForm(Form2);
end;

Execute Button1.Click will make Form2 as mainform and update the Windows’ taskbar thumbnail preview. However, the Taskbar may flicker on the switching.

My questions are:

  1. Is there any way to away such flickering?
  2. Is it safe to set Application.MainformOnTaskBar := False and set it to True again in runtime?
  • 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-05-18T08:01:12+00:00Added an answer on May 18, 2026 at 8:01 am

    The main form isn’t something you’re allowed to change in Delphi. You managed to find a way that appears to work half-way, but it’s a hack. Stop doing that.

    An application has only one main form, and it’s the first form that finishes being created via CreateForm. If you need two radically different behaviors for the main form, then you can try a couple of techniques:

    • Define your two main forms as frames. Put all your functionality there. Then define a single form that will act as the parent of one of the two frames. Instead of switching the main form, simply destroy the frame and replace it with a new one.

    • Similar to the frame solution, but use forms instead. Create the forms, and set the Parent property to be the “real” main form. This will probably have a lower initial cost because you already have the two forms, but in my experience, re-parenting forms is more fragile than frames, which were designed for being child controls, so prefer the frame technique.

    The flicker on the taskbar comes from one form disappearing and another appearing. With either technique above, there’s always just one form, never two, so there’s nothing to flicker.

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

Sidebar

Related Questions

I am using Firebird on Windows (Delphi 2010 developed Application). Is it possible to
Is there a way (on windows using Delphi 2010) to get the number of
I need to read from and write to Excel spreadsheets using Delphi 2010. Nothing
I'm using the line below to have MSBuild build a Delphi 2010 groupproj: MSBuild
I am using Delphi 2010, and when I created a console application that prints
I am using Delphi 2010 to implement an Application Menu for my ribbon control...
I am using Delphi 2010, latest version (from repository) of JEDI WinAPI and Windows
I am using Delphi 2010 and if I create a new VCL application, drop
I am developing an application in Delphi-2010 using SQL Server 2008 R2 in network
I'm using delphi 2010, is there anyway to know running threads count of the

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.