Hi all,

I want to ask you for little help. I make application in C#. It is made from one main form and it would be great if I can use as a part of it another "small forms" (I want to let user drag them on screen where they want). I have problem to describe it :) I want to make something like tool, colors layers or history box in Paint.NET.

http://www.getpaint.net/screenshots/pdn35_kirkland.jpg

You can drag them where you want, close them or open again while main form is intacted. But you also can minimalize whole app in the tray (at once, not window by window).

But how? Is there some trick? Or I just cats "minimalize" event and change hide/close all windows? Thx for reply to all!

Recommended Answers

All 7 Replies

Hi welcome!
Use MDI (Multiple Document Interface)
You could start here for more info.
Or look at this http://msdn.microsoft.com/en-us/library/aa645520(v=vs.71).aspx

commented: Fast and right answer. +0
commented: As always :) Wish you and your family a Merry Christmas! +11

Thank you for your reply! Thats what I need :)

But a little problem here - I use MSDN article http://msdn.microsoft.com/en-us/library/7aw8zc76.aspx and button on main form runs this code:

this.IsMdiContainer = true;

   Form2 newMDIChild = new Form2();
   newMDIChild.MdiParent = this;
   newMDIChild.Show();

...but nothing happened. When I delete line "newMDIChild.MdiParent = this;" it is working, but of course not like parent & child. Can you help me fin out where can be mistake?

EDIT: There is big picture above whole form (not as background). But it can not affect this, am I right?

Try setting the IsMdiContainer property from the properties box. (Not in your event method)

You can set IsMdiContainer to true within the Form1.Designer.cs file or after InitializeComponent() in the forms constructor.

I find out, that problem is in picturebox and other components of MainForm. Situation:

Mainform with some buttons and big picturebox which covers whole form (like background). I create MDI child, it is there - but it is "under" all parts which are on MainForm. So this big image overlaps it. I need to get MDI Child in the front of it (BringToFront does not work, Form.TopMost does not work).

OK, after few hours of testing I have nothing :/. I find some thread where was guy trying to do same thing. They also did not find any solution.

So I change the way, use regular forms, catch events of minimalization/maximalization and apply them to all forms.

Don't use a pictureBox for this.
Use the BackGroundImage property of the form.
See the zipped example.
Succes!

you might want to take a look at this great library: DockPanel suite

http://sourceforge.net/projects/dockpanelsuite/

It works very well and i think this is what you are looking for. It is basically a A Visual Studio like Interface which allows you to dock forms into the main form.

check it out, i think it will help

Regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.