Tracking Child Windows
Posted on 2003-11-13
My MDI text editor application creates child windows with the following code:
Form2.Tag := MDIChildCount;
Each window has a memo component and important info is stored in arrays. When I access a child window, it's Tag property tells me that window's number so I know what array element to access.
I save the memo's contents to disk with:
(ActiveMDIChild as TForm2).Memo.Lines.SaveToFile(SaveFName);
I was told that this method wouldn't work with the arrays, but all my tests showed that it seemed to be fine. However, I should have listened because after more serious testing, I have discovered that I was wrong and it really doesn't work.
If you open say 5 child windows, then close window 3 there are four left so creating another window creates one with the same number as an existing one and all my array data gets all mixed up.
Is there a method of keeping track of multiple child windows where any number can be created and deleted in any order as and when required?