Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Here is what I want to do:

 

I have an MDI form and it has a tool dialog docked to the right side. I want to keep it on top of all other MDI child Forms and if possible remove the portion it takes from the MDI client frame.

 

Can anyone help me by explaining how I should do this?

 

Thanks in advance

 

Napivo

 

got this:

 

So what can you do ?

 

Here's how to set up an MDI application so that MDI childs operate normally, but some child windows always stay on top. (there is a simple trick � )

 

How do we�ll do it ?

1. The always-on-top child is not an MDI child ! � Don�t set its MdiPatent property

2. We will achieve the child�s behavior for this form by calling the win32 api SetParent( child.hwnd, parent.hwnd)

 

Follow these instructions to set up a simple demonstration:

 

1. Open visual studio

2. Create a windows application

3. Rename Form1 to MainForm and change the IsMdiContainer property to true.

4. Add two new Windows Forms to the project and name them frmMdiChild and frmAlwaysOnTop

5. Add the flowing lines to the MainForm load event:

 

frmMdiChild child1=new frmMdiChild();

child1.MdiParent=this;

child1.Show();

 

frmMdiChild child2=new frmMdiChild();

child2.MdiParent=this;

child2.Show();

 

frmAlwaysOnTop topform=new frmAlwaysOnTop();

topform.Show();

SetParent((int)topform.Handle,(int)this.Handle); <<< Here is the Magic :-)

 

6. Add declaration of the SetParent win32api to the MainForm class:

[DllImport("user32")] public static extern int SetParent(int hWndChild, int hWndNewParent) ;

 

 

The only problem is:

 

6. Add declaration of the SetParent win32api to the MainForm class:

[DllImport("user32")] public static extern int SetParent(int hWndChild, int hWndNewParent) ;

 

 

How can I do this in Microsoft Visual Studio 2008 Express?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...