An application from Delphi 1 (16 bit) has been transferd into Delphi 2007. The main form is always shown behind all other forms, whatever I do.

How can I get the normal action from the form, so it is shown on top when it is active.

Thanks in advance

there have been a huge number of changes.. since then.. when you say it shows behind the other forms, is it forms within the app, or forms within your desktop?

While it would be a hack you could tell it to bringtofront, but, Im thinking theres some form props or something that has changed its not picking up correctly.

there have been a huge number of changes.. since then.. when you say it shows behind the other forms, is it forms within the app, or forms within your desktop?

While it would be a hack you could tell it to bringtofront, but, Im thinking theres some form props or something that has changed its not picking up correctly.

It will show on top of forms, belonging to other applications, but behind all forms belonging to its own application.
"Bring to front" is not available for a form at design time at least. Can it be done in runtime?

I have compared all properties to other forms in this application without finding any differences.

Even if I set FormStyle to fsStayOnTop my main form will stay behind all the rest forms in this application, but on top of other applications.

Well question:

How are you opening the other forms?

I open the other forms like:

FrmNotes.show;

if it only then applies to the mainform, check the dpr file on how its created

I tried to set an other form to be my main form, but then that other form got the same property.

My dpr file looks like:

program NotEdit;

uses
  Forms,
  NOTEDI1 in 'NOTEDI1.PAS' {Form1},
  BLOCK in 'BLOCK.PAS' {FrmBlock},
  Convert in 'Convert.pas' {FrmConvert};

{$R *.res}

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

Does it happen if you make a new form and have that as your main form (and no you didnt set the new thing as your main form you just made it visible at startup)

Then my new main form will inherit the strange behaviour and my old main form will act normally!

That doesnt sound normal.

I would expect if you made a new form with a button saying "click me" and it opened the original main form that the issue would be gone.

I think the problem was solved. There was a line:

Application.MainFormOnTaskbar := True;


in the .DPR file. I have no idea about how it got there. Don't know what it is supposed to do but when I removed it the form is fine.

Thanks for taking your time.

Thats required usually in D2007 otherwise you end up with ghosted forms and lack of form on the task bar

Insert the following declaration in the protected section of the child form

procedure CreateParams(var Params: TCreateParams) ; override;

In the body of the child form, insert the body:

procedure TChildForm.CreateParams(var Params: TCreateParams) ;
  begin
    inherited;
    Params.WndParent := GetDesktopWindow;
  end;

The child form's parent is now the desktop rather than the main form, allowing the two to be manipulated independently

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.