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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:39:07+00:00 2026-06-17T16:39:07+00:00

My application is based of a MainForm, DetailForms and DialogForms. On the taskbar I

  • 0

My application is based of a MainForm, DetailForms and DialogForms.
On the taskbar I can see the MainFormButton and also the DetailForms.
Therefore I use:

procedure <DetailForm>.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent:= GetDesktopWindow;  
end; 

I use delphi 2010 and I’ve set Application.MainFormOnTaskbar:= True;
When I use PromptForFileName or TSaveDialog in the Detailform then the DetailForm go behind the Mainform.
The DetailForm come back after closing the dialog.

When I use DialogForm (Showmodal of TForm with property PopupMode: pmAuto) then my DetailForm is stay between the main and dialog.
How can I force the TSaveDialog like a showmodal with property PopupMode: pmAuto or how can i prevent that my detailform goes behind the mainform

Demo:

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

  {$R *.res}

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

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ImgList, ActnList;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  oForm: TForm;
begin
  oForm:= Unit2.TForm2.Create(Self);
  oForm.Show;
end;
end.

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm2 = class(TForm)

    SaveDialog1: TSaveDialog;
    procedure cxButton1Click(Sender: TObject);
  private
  protected
    procedure CreateParams(var Params: TCreateParams); override;
        { Private declarations }

  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

{ TForm2 }

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent:= 0;   // --> Testing
end;

procedure TForm2.cxButton1Click(Sender: TObject);
begin
  self.SaveDialog1.execute();
end;

end.
  • 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-17T16:39:08+00:00Added an answer on June 17, 2026 at 4:39 pm

    Step 1 is that you must not make the desktop window the owner of your form. Raymond Chen explains why not.

    To really understand what’s happening you need to read Window Features on MSDN to get a clearer understanding of window ownership. And be very careful that window ownership is a concept completely unrelated to Delphi component ownership. In Delphi terms, window ownership is controlled by the PopupParent property.

    As has been clarified in comments, you want both forms to be unowned, top-level windows. The main form automatically is that. For the details form you need to set WndParent to 0 and that’s it:

    procedure <DetailForm>.CreateParams(var Params: TCreateParams);
    begin
      inherited;
      Params.WndParent := 0;
    end; 
    

    The final step is to make sure that the save dialog is owned properly. To do that specify the owner when you call Execute:

    Self.SaveDialog1.Execute(Self.Handle);
    

    So, in summary you need to make three changes:

    1. Set the detail form’s WndParent to 0.
    2. Remove the WS_EX_APPWINDOW extended style, it is not needed for an unowned top-level window.
    3. Pass the detail form’s handle when calling Execute on the save dialog.

    Update

    It turns out that you are using XP, and the Delphi code that shows the file dialog is rubbish. Although you pass a handle to the Execute method, that is ignored and the main window handle is used as the dialog’s owner. And that’s why the main window comes to the front.

    You can get around this by setting Application.ModalPopupMode to pmAuto. You should probably set this in your .dpr file.

    Read more about this here: https://web.archive.org/web/20140806033012/https://blogs.embarcadero.com/abauer/2005/09/30/21517 (on archive.org because the original page does no longer exist)

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

Sidebar

Related Questions

I have an application based on google map, in which I need to use
I am developing a web application based on JSF technology. I use Eclipse as
I am developing application based on the NetBeans platform. I use Maven to build
Hello I have application based on data retrieved over internet... How can I handle
In my application (based on the Tab bar application XCode template) I use a
We have a web application based on NSpring 1.2 and NHibernate 2 and use
I have application based on NSDocument (NSPersistentDocument), in application I can create (as usually)
My application is based on modal forms. Main form opens one form with ShowModal,
We are developing an application based in an Embedded Infinispan Data-grid cluster. In the
I have typical web application based on PHP, HTML, and javascript. From an HTML

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.