protected override void WndProc(ref Message m)
{
if (m.Msg == (int)Msgs.WM_NCLBUTTONDOWN)
{
if (IsDisposed)
return;
uint result = NativeMethods.SendMessage(Handle, (int)Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
if (result == 2 && this.DockPanel.AllowEndUserDocking && this.AllowEndUserDocking) // HITTEST_CAPTION
{
Activate();
this.m_dockPanel.BeginDrag(this);
}
else
base.WndProc(ref m);
return;
}
else if (m.Msg == (int)Msgs.WM_NCRBUTTONDOWN)
{
uint result = NativeMethods.SendMessage(Handle, (int)Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
if (result == 2) // HITTEST_CAPTION
{
DockPane theOnlyPane = (this.VisibleNestedPanes.Count == 1) ? this.VisibleNestedPanes[0] : null;
if (theOnlyPane != null && theOnlyPane.ActiveContent != null)
{
theOnlyPane.ShowTabPageContextMenu(this, PointToClient(MousePosition));
return;
}
}
base.WndProc(ref m);
return;
}
else if (m.Msg == (int)Msgs.WM_CLOSE)
{
if (this.NestedPanes.Count == 0)
{
base.WndProc(ref m);
return;
}
for (int i = this.NestedPanes.Count - 1; i >= 0; i--)
{
DockContentCollection contents = this.NestedPanes[i].Contents;
for (int j = contents.Count - 1; j >= 0; j--)
{
IDockContent content = contents[j];
if (content.DockHandler.DockState != DockState.Float)
continue;
if (!content.DockHandler.CloseButton)
continue;
if (content.DockHandler.HideOnClose)
content.DockHandler.Hide();
else
content.DockHandler.Close();
}
}
return;
}
else if (m.Msg == (int)Msgs.WM_NCLBUTTONDBLCLK)
{
uint result = NativeMethods.SendMessage(Handle, (int)Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
if (result != 2) // HITTEST_CAPTION
{
base.WndProc(ref m);
return;
}
this.DockPanel.SuspendLayout(true);
// Restore to panel
foreach (DockPane pane in this.NestedPanes)
{
if (pane.DockState != DockState.Float)
continue;
pane.RestoreToPanel();
}
this.DockPanel.ResumeLayout(true, true);
return;
}
else if (m.Msg == WM_CHECKDISPOSE)
{
if (this.NestedPanes.Count == 0)
Dispose();
return;
}
base.WndProc(ref m);
}