Solved

Changing the ActiveMDIChild

Posted on 1998-07-28
4
1,722 Views
Last Modified: 2008-02-01
Hi

I have a problem that I hope that some of you can help me with.

How do I set the active MDI child of a form ???

I have a form (Form1) with FormStyle=fsMDIForm and two other forms (Form2 and Form3) both with FormStyle=fsMDIChild - they are MDIChilds of Form1. I want to be able to change the ActiveMDIChild of Form1 to say Form2 - how do I do that. If there is no controls on Form2 it is easy done with Form2.SetFocus, but if there is some controls on Form2 Form2.SetFocus just called SetFocus of the ActiveControl of Form2 and Form2 will not nessacary become the ActiveMDIChild of Form1.

There must be a way to change the ActiveMDIChild of Form1, even though the form that you want to become the ActiveMDIChild has some controls on itself. Right now I cheat to do it ...

var
  AWC : TWinControl;

...

AWC := Form2.ActiveControl;
Form2.ActiveControl := nil;
Form2.SetFocus;
Form2.ActiveControl := AWC;

... but cant anyone tell me a better way to do it ???

Thanx Steff
0
Comment
Question by:steff
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1358906
Hello Steff,

If there are only two forms, and you don't add any other Child forms you can use NameOfMDIForm.Next; which will center the focus on the next form, and if the focus is on Form1MDIChild, the focus would be on Form2MDIChild, no matter if there are other controls on the form... This is a solution if there are only two MDIChold Forms...remmeber that!

Regards,
Viktor Ivanov
0
 

Author Comment

by:steff
ID: 1358907
Sorry, but the example with to two forms was just an example.

I work with alot of MDIchilds.

Can anyone help me !??!

To victornet: If there is no answer to my quenstion in the next to days just post another answer and I will give you the points - your answer was a good try ;-)

Steff
0
 
LVL 10

Accepted Solution

by:
viktornet earned 30 total points
ID: 1358908
Hey Steff, How R Ya doing?

A little research and I think this would it...I tried it here and it works, now it's your turn...
(*****************************)
Form2.BringToFront;
Form3.BringToFront;
NameOfMDIChild.BringToFront;
(*****************************)
If you set the BringToFront on the MDIForm like(MDIForm.BringToFront) it will become the top control of all windows, but when you set the BringToFront of a MDIChild then it becomes the top form only in the MDIForm so this way trick should work...

Regards,
Viktor Ivanov

0
 

Author Comment

by:steff
ID: 1358909
Yes, how simple can it be - BringToFront was just the answer for me. Thanx !

Steff
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

13 Experts available now in Live!

Get 1:1 Help Now