1,105,177 Community Members

Main form is always shown behind other forms

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
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.

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
0
 

Well question:

How are you opening the other forms?

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I open the other forms like:

FrmNotes.show;
Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
0
 

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

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.
Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
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)

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
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.

Member Avatar
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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
Member Avatar
LizR
Posting Virtuoso
1,735 posts since Aug 2008
Reputation Points: 171 [?]
Q&As Helped to Solve: 190 [?]
Skill Endorsements: 4 [?]
 
0
 

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

Member Avatar
DanHamm
Newbie Poster
1 post since Sep 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-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