Solved

Changing the ActiveMDIChild

Posted on 1998-07-28
4
1,753 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

695 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