About MDI (Question 1)

I tried to add a TabSet to my MDI application and I want it in such a way that when I click on the TabSet, the corresponding MDI Child Window will be shown.

But I've noticed that the TabSet's Index and the MDIChildren array does not correspond (i.e. the index 0 in MDIChildren refers to the active Child Window but the index 0 in TabSet refers to the first Tab)

How do I solve this??

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What you can do is this : Name your tab to the name of your child menu. If the tab is triggered you can call this code :
  ChildIndex := 0
  while (ChildIndex < frmMDIParent.ChildCount) and
        (frmMDIParent.MDIChildren[ChildIndex].Name <>
         {TabName}) do Inc(ChildIndex);
    if ChildIndex <> frmMDIParent.ChildCount then begin

But normally if give the same index of your child to the corresponding tabindex it would offcourse be easier, but it looks like you've already tried that out :


Besides, normally the index of the active MDIChild can be found with ActiveMDIChild! And I don't think it's always index 0!!

Have fun,
c.u. ZifNab;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WizKidAuthor Commented:
My Child doesn't have a menu...
So any other way??
Sorry, my mistake (how the hell to I come to menu???) Just call the tab to the name of your child name! Or define an array, where the corresponding numbers (tabs) have the name of your child.
Or just use something where you can store the name of the child to the corresponding tabindex. With the first example, you search through the list of names, if you found it you can go to the corresponding tabpage.
Doesn't example 2 works????
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Hi WizKid,

look at this sample code :


Sample of MDI with tabset, flickerless, ....

All what you need.

Merry X-Mas & Happy New Year!
Have fun,
c.u. ZifNab;
WizKidAuthor Commented:
Have already seen his sample code but it causes a runtime error when I click on my close all button

The piece of code for my close all procedure is as follow
procedure CloseAll;
  i : integer;
  for i:=MDIChildCount-1 downto 0 do
Have you put this into the OnClose event of the Childform('s)?

 Action := caFree;

This has to be done!.
WizKidAuthor Commented:
I've already done that...
When do you get the error?
At which i value? At beginning or end?
WizKidAuthor Commented:
I've solve it already...
Thanks for helping me all along :-)

email: wenwei@mbox2.singnet.com.sg
webpage: http://web.singnet.com.sg/~wenwei/index.html

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.