No MDI borders?

J

Jacob

I'm trying to create an MDI form where the MDI area dosn't have the
traditional 3D borders. I thought at one point the code I had in the form
constructor was working, but now I'm getting an MDI without borders, but the
main menu on my form no longer appears. Anybody who has a little more
experience with this and is willing to help, I would appreciate it.

Thanks,
Jacob



// In MDI form constructor, after InitializeComponent.
for(int i = 0; i < this.Controls.Count; i++)

{

mdiClient = Controls as System.Windows.Forms.MdiClient;

if(mdiClient != null)

{

// Get Styles using Win32 calls

int style = Win32.GetWindowLong(mdiClient.Handle, Win32.GWL_STYLE);

int exStyle = Win32.GetWindowLong(mdiClient.Handle, Win32.GWL_EXSTYLE);

// Remove any borders on the Mdi.

style &= ~Win32.WS_BORDER;

exStyle &= ~Win32.WS_EX_CLIENTEDGE;


// Set Styles using Win32 calls

Win32.SetWindowLong(mdiClient.Handle, Win32.GWL_STYLE, style);

Win32.SetWindowLong(mdiClient.Handle, Win32.GWL_EXSTYLE, exStyle);

break;

}

}
 
M

Microsoft

Well, I think I got it figured out. When the code is placed in the
constructor it fails because the form and hence the MdiClient have not
gotten bounds yet. Without bounds, the function treats the whole form as the
mdi area, leaving no room for the menu, and that is what is causing the menu
to disappear.

Just put the code in the load event or other appropriate spot.

Jacob
 
M

Microsoft

Oh ya, you'll need to force the MdiClient to be recreated. Placing this
directly after the first snippet is one way.




Win32.SetWindowPos(mdiClient.Handle, IntPtr.Zero, 0, 0, 0, 0,

Win32.SWP_NOACTIVATE | Win32.SWP_NOMOVE | Win32.SWP_NOSIZE |
Win32.SWP_NOZORDER |

Win32.SWP_NOOWNERZORDER | Win32.SWP_FRAMECHANGED);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top