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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:07:15+00:00 2026-05-26T03:07:15+00:00

I am dynamically creating a Form that overrides the CreateParams so that I can

  • 0

I am dynamically creating a Form that overrides the CreateParams so that I can have it displayed on the TaskBar. From the dynamically created Form, I am calling a TColorDialog but once it is displayed my Form will go under the MainForm with the ColorDialog on top of that.

After the ColorDialog is closed the dynamic Form will return back over the MainForm.

I see that on the ColorDialog Execute method there is a Handle that can be passed but I am not sure if I am on the right track with that?

If I click under the Dialog on the MainForm it will flash but how can I have the dynamically created Form “own” this Dialog with the MainForm at the back?

I create the Form like this:

procedure TMain.Button1Click(Sender: TObject);
var
  SEMArcF: TWriteSEMArcFrm;
begin
  SEMArcF := TWRiteSEMArcFrm.Create(nil);
  SEMArcF.Show;
end; 

and it is freed on the OnClose Event:

procedure TWriteSEMArcFrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

I am overriding the CreateParams like this:

procedure TWriteSEMArcFrm.CreateParams(var Params: TCreateParams);
begin
  inherited;
  if (FormStyle = fsNormal) then begin
    Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
    Params.WndParent := GetDesktopWindow;
  end;
end;

and to show the ColorDialog I either create it or just have a TColorDialog Component on the Form, either way will result in the same. I want it to be owned by the dynamic Form.

EDIT
I now add:

Application.ModalPopupMode := pmAuto;

The full code:

procedure TWriteSEMArcFrm.btnBackColourClick(Sender: TObject);
var
  ColorDlg: TColorDialog;
begin
  Application.ModalPopupMode := pmAuto;
  ColorDlg := TColorDialog.Create(nil);
  try
    if ColorDlg.Execute then
    re.Color := ColorDlg.Color;
  finally
    ColorDlg.Free;
  end;
end;

This works fine but could there be any unusual behaviour by setting this?

Thank you

Chris

  • 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-26T03:07:16+00:00Added an answer on May 26, 2026 at 3:07 am

    TColorDialog derives from TCommonDialog, which has two overloaded versions of Execute() available – the legacy parameterless version that has existed for years, and a newer overload that takes a parent HWND as an input parameter. You are likely calling the former. That overload uses the Handle property of the currently active TForm (only if the TApplication.ModalPopupMode property is not set to pmNone), falling back to the Handle of the MainForm if needed. If you want more control, you should call the other overload directly instead, then you can pass the dynamic form’s Handle property as the parameter value.

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

Sidebar

Related Questions

I have an ASPX page that is dynamically creating a gridview from a database
I have a several form elements that I am dynamically creating with javascript when
I am creating a form dynamically from the fields returned from server using json
how can I go about creating a form with javascript? I have NO idea
I am creating a form dynamically, however the routine that closes it, is located
I am dynamically creating buttons from an array that is dynamically loaded. I am
I would like to create a form that changes dynamically. I have a form
I have a program that I am creating that creates task inputs dynamically. My
I am dynamically creating forms from a JSON object that I fetch with a
Using DTS I'm dynamically creating an access database. After the file is created (which

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.