Delphi MDI - handling open/close/activate child form

migajek picture migajek · Sep 15, 2009 · Viewed 9.4k times · Source

I'm developing MDI application which assigns a tab for each created MDI child. I need to "catch" OnActivate, OnCreate and OnDestroy events of child form in the main (parent) form code. Simply calling the code in children form is impossible for me, as there are many form's classes that are used as MDI children, also the plugin can load it's own form...

So, my question is: how to catch that MDI child form has been activated/deactivated without using child form's events ?

Answer

Vivian Mills picture Vivian Mills · Sep 15, 2009

I wrote a Taskbar type of component a bunch of years ago that does just this type of thing. It's called TrmMDITaskbar. You can find a copy of it on Torrys, it's a part of the rmControls library package. It handles activation, minimizing, maximizing etc.

The gist of how it works is that it hooks the MDIParents window handle looking for MDIChild events and does stuff based on those events.

If you're looking to write your own I would suggest that as a good place to start.

Ryan.

P.S. The version on Torrys is a little older but should still work. I do have a newer version available on my support website. (Mills Enterprise)