Solved

avoiding forms to come to the foreground

Posted on 2001-09-14
9
419 Views
Last Modified: 2010-04-06
I have several forms in my app(that have 'Application' as parent).
when I click one of them all the other forms come to the foreground
(in relation to other app's forms that exist on the screen and NOT
to the foreground of every form, includind the ones in the same app)

I want only the form I clicked to be selected leaving all the other
forms on their respective Z order.



   Thaks in advance

         Filipe Correia
0
Comment
Question by:filipecorreia
  • 5
  • 2
  • 2
9 Comments
 
LVL 3

Accepted Solution

by:
cubud earned 200 total points
ID: 6485982
In each form you want to behave in this way do this

type
  TForm2 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
    procedure CreateParams(var Params: TCreateParams); override;
  end;

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

This makes the desktop the owner of this form.  This means that minimizing the main form or bringing it to the foreground does not affect this form.

Taken from http://www.howtodothings.com/showarticle.asp?article=16


Pete
====
http://www.HowToDoThings.com (Articles)
http://www.Stuckindoors.com/delphi (Open source)
0
 
LVL 1

Author Comment

by:filipecorreia
ID: 6486989
Hi
I think your answer may be what I need but I need some more info.
I'm really using C++ Builder but I think this code will work also. only... maybe somethings I have to do in a different way. I have some questions about that:


why is "override;" called? I guess it is only to state that the fuction will be overriden. is that right?

Why is "inherited;" called? is it to call the original function(before it was overriden)?


  Thanks in advance

        Filipe Correia
0
 
LVL 1

Author Comment

by:filipecorreia
ID: 6491651
I've been doing some researching and I think that I now know how to do it in C++.
Any way... if you can help me on this part I would appreciate it.


   Thanks
 
         Filipe Correia
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:cubud
ID: 6493083
The answer I gave was correct.
You asked how to do something in Delphi not C++Builder !  

My answer is still correct, you just need to translate into C++ Builder.

Override is called because you want the original control to call our new CreateParams rather than its own.  I call inherited before our new code so that we can get the original result and then modify it.

Pete
====
http://www.HowToDoThings.com (Delphi Articles)
http://www.Stuckindoors.com/delphi (Open source)
0
 
LVL 1

Author Comment

by:filipecorreia
ID: 6499181
Hi


It's working... I've done as you said and the app is behaving like I whanted it to. Except...

There's only an issue left about wich I hope you can help me.
In my app I have a system tray Icon. When I click in it, to bring up it's popup
menu, the last form that had focus comes to the foreground of any other form.
This wasn't supose to hapen. By clicking the system tray icon the popup menu
should appear (as it does) but the any form's z order should remain intact.


    Thank you again

          Filipe Correia


PS:
> This issue is worth some extra points if you can help me
> Thanks for the sites. They've been very useful
0
 
LVL 17

Expert Comment

by:geobul
ID: 9308071
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

accept cubud's comment as answer

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0
 
LVL 1

Author Comment

by:filipecorreia
ID: 9312896
I agree, this question should be cleaned up.

   Cheers,
       Filipe
0
 
LVL 17

Expert Comment

by:geobul
ID: 9329564
Hi Filipe,

You may close it yourself by accepting cubud's comment as answer. Otherwise site moderators will.

Regards, Geo
0
 
LVL 1

Author Comment

by:filipecorreia
ID: 9335249
done :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question