How to use Child Forms as ToolBoxes?

firas489

Member
Joined
Apr 25, 2008
Messages
14
Programming Experience
5-10
Hello everyone,

I was thinking lately if it is possible to use a child form in a parent form as a toolbox, same as the ones in Visual Basic/Studio?

What im trying to say, is that is it possible for me to create the child form that will behave like the ones in visual basic, for example, if you double click on it, instead of maximizing, it will be attached to the parent form.
A specific example is the Command Window - Immediate ?


Hope i made sense,


Thanks,

Best Regards
Firas S Assaad
 
The child forms and MDI applications have many limitations from the base Windows API. I successfully made tabbed child windows with a custom border (similar to photoshop but without the normal toolbox border) an it required lots of hacking my way through limitations and bugs.

My guess is you're better off using a normal form and limiting its area to that of the parent or create a custom panel that can be dragged out (so you add it as is to another panel when it exits the parent's area) with code from the moment you want something more or less customized.

Maybe I made things hard for myself and the stuff I wanted to do could be done in an easier way, but I never found how (I'm not too good with the WinProc overridable method...). Maybe you could build a prototype of what you want and throw it away if the easy way can't be done (I usually scrap the prototypes no matter the outcome and rewrite from nothing).
 
Toolbox windows is a standard setting, you set Window style (FormBorderStyle) to fixed/sizable Tool window and attach it to parent by assigning Owner/OwnedForms. Also set ShowInTaskbar=False.

"Docking" it is a little more difficult, one way could be calculating the location and place it, then use parent Move event to let it follow, probably best for "outside" docking. Another could be parenting the form for example in a panel when it's "docked" inside the parent form. Setting TopLevel=False is necessary to parent a form as another forms control. It's one of those puzzles, and must be common one, have you tried a search also?
 
When you mentioned "like Visual Studio", I assumed you meant custom docking, custom border, undocking from the parent form as needed...

The problem is that I found many configurations of the MDI childs to be buggy... You will find that when you set the FormBorderStyle to None, you will see the default border flicker before your custom border is painted whenever the child form becomes visible. At the time I found a Microsoft blog entry describing this as a know bug with a complicated workaround...

A quick search found many different problems, mostly small annoyances but still, I know for having tried that there are lots of problem with those MDI forms... What I mean is, it may work just fine, you may have to hack the thing into a working control or you may just end up wasting time. You're better to prototype the thing first and see if you can avoid anything that doesn't work...
 
Note that toolbox windows are not to be configured as MDI childs, they are not document windows. MDI is "multiple document interface". MDI childs also can't be moved outside the parent form like toolbox windows do.
 
Back
Top