Solved

avoiding forms to come to the foreground

Posted on 2001-09-14
9
391 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now