We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,721 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Main form is always shown behind other forms

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

3
Contributors
13
Replies
3 Years
Discussion Span
1 Year Ago
Last Updated
14
Views
Question
Answered
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 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.

AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Well question:

How are you opening the other forms?

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 0

I open the other forms like:

FrmNotes.show;
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 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.
AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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)

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 0

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

AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 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.

AKJo
Junior Poster in Training
59 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 4 Years Ago by LizR

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

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
Skill Endorsements: 0

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

DanHamm
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1078 seconds using 2.69MB