1.11M Members

Main form is always shown behind other forms

 
0
 

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

 
0
 

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.

 
0
 

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.

 
0
 

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.

 
0
 

Well question:

How are you opening the other forms?

 
0
 

I open the other forms like:

FrmNotes.show;
 
0
 

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

 
0
 

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.
 
0
 

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)

 
0
 

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

 
0
 

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.

 
0
 

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.

Question Answered as of 5 Years Ago by LizR
 
0
 

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

 
-1
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article