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'm using Delphi and need to get the current Windows DNS server IP address
I`m using Delphi 2009 and want to operate some XML data. I heard that
When using Delphi IDE, it will silently change SQLConnection.Connected to true when populating field
I'm using Delphi 6, and I want a database bound list box with multiselect.
I'm using Delphi 2007. How can I put a GIF/PNG image on a BitBtn
I am using Delphi 7 and ICS components to communicate with php script and
I am using Delphi TApplication.OnException Event to catch unhandled exceptions This works well but
I need to compress multiple files into a single archive using Delphi. I'd prefer
Are there any utilities that reformat Delphi code ? EDIT I am using Delphi
I'm using standard Delphi constants DayMonday, etc and I want to convert them to

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.