?
Solved

Changing the ActiveMDIChild

Posted on 1998-07-28
4
Medium Priority
?
1,760 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 120 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

752 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