Solved

Changing the ActiveMDIChild

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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