
Untitled
By: a guest on
May 26th, 2012 | syntax:
None | size: 1.83 KB | hits: 13 | expires: Never
C# MDI - how do I prevent the scroll bar?
namespace Controls
{
public partial class BaseForm : Form
{
public BaseForm()
{
InitializeComponent();
StartPosition = FormStartPosition.WindowsDefaultLocation;
MaximizeBox = false;
Width = 806;
//Width = 850;
//Height = 760;
Height = 730;
//Width = 790;
//Height = 617;
}
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;
//ShowScrollBar(this.Handle, (int)ScrollBarDirection.SB_BOTH, false);
switch (m.Msg)
{
case WM_SYSCOMMAND:
int command = m.WParam.ToInt32() & 0xfff0;
if (command == SC_MOVE)
return;
break;
}
base.WndProc(ref m);
}
}
}
public partial class childform : BaseForm
{
.......
}
internal class MyNativeMDIclient : NativeWindow
{
private MdiClient mdiClient;
public MyNativeMDIclient(MdiClient parent)
{
mdiClient = parent;
ReleaseHandle();
AssignHandle(mdiClient.Handle);
}
internal void OnHandleDestroyed(object sender, EventArgs e)
{
ReleaseHandle();
}
private const int SB_BOTH = 3;
[DllImport("user32.dll")]
private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);
protected override void WndProc(ref Message m)
{
ShowScrollBar(m.HWnd, SB_BOTH, 0 /*false*/);
base.WndProc(ref m);
}
}
foreach (Control control in this.Controls)
{
if (control is MdiClient)
{
MyNativeMDIclient nw = new MyNativeMDIclient(control);
break;
}
}