Solved

Changing the ActiveMDIChild

Posted on 1998-07-28
4
1,746 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 106
PHP preg_replace code convert to Delphi 14 82
MS Access from Delphi 31 81
Firemonkey how to swip panel with finger tap 1 24
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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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