C #: How to remove scrollbars from mdi parent?
Well, I just finished checking several related questions and one seemed to have an answer, but the link was broken and the other is not well pointed out.
I am just trying to remove the scrollbars in the mdi parent home when the child is moved outside the parent boundaries.
http://img224.imageshack.us/img224/4788/mdiscrollbars.jpg
What I am trying to accomplish is to reproduce menus that can be displayed within the mmo that you can move in and out of the screen. I assumed it was with multiple forms, but if I am wrong or I am not doing it easily, please correct me.
a source to share
How about something like this. You are getting minor flickering, but I'm sure there is a workaround for this:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
private const int SB_BOTH = 3;
private const int WM_NCCALCSIZE = 0x83;
[DllImport("user32.dll")]
private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
protected override void WndProc(ref Message m)
{
if (mdiClient != null)
{
ShowScrollBar(mdiClient.Handle, SB_BOTH, 0 /*Hide the ScrollBars*/);
}
base.WndProc(ref m);
}
MdiClient mdiClient = null;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control c in this.Controls) //Find the MdiClient in the MdiWindow
{
if (c is MdiClient)
{
mdiClient = c as MdiClient;
}
}
Form2 newChild = new Form2();
newChild.MdiParent = this;
newChild.Show();
}
}
}
a source to share
I found this which uses interop.
The link also shows how to prevent the child form from moving outside of the parent mdi boundaries.
The code in the link does the trick, but you need to add the following directive:
using System.Runtime.InteropServices;
As mentioned in the linked thread, there is a bit of flicker, but you can try it.
a source to share