From: http://www.cnblogs.com/yvesliao/archive/2008/08/26/1276609.html
1. When you double-click a tab, the current tab is directly separated from the frame of the main form to form a floating form. This is not what I want. I changed it to double-click to close it.
In the wndproc method of dockpanestripbase. CS, the left-click message is re-processed (the comment below is the original method, and the line below is changed ):
[Securitypermission (securityaction. linkdemand, flags = securitypermissionflag. unmanagedcode)]
Protected override void wndproc (ref message m)
{
If (M. MSG = (INT) win32.msgs. wm_lbuttondblclk)
{
Base. wndproc (ref m );
Int Index = hittest ();
If (dockpane. dockpanel. allowenduserdocking & Index! =-1)
{
Idockcontent content = tabs [Index]. content;
// If (content. dockhandler. checkdockstate (! Content. dockhandler. isfloat )! = Dockstate. Unknown)
// Content. dockhandler. isfloat =! Content. dockhandler. isfloat; // indicates that the window is restored to the initial size and is detached from any dock.
If (content. dockhandler. hideonclose)
Content. dockhandler. Hide (); // hide
Else
Content. dockhandler. Close (); // close
}
Return;
}
Base. wndproc (ref m );
Return;
}
2. Many forms have a right-click menu in the tab, and the right-click menu is closed, so it is best to inherit dockcontent so that other forms have this right-click menu as long as they inherit it.
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Namespace WeifenLuo. WinFormsUI. Docking
{
Public class DockContentEx: WeifenLuo. WinFormsUI. Docking. DockContent
{
// Right-click the tag to display the close menu
Public DockContentEx ()
{
ContextMenuStrip cms = new System. Windows. Forms. ContextMenuStrip ();
ToolStripMenuItem tsmiClose = new System. Windows. Forms. ToolStripMenuItem ();
//
// Cms
//
Tsmiclose. Name = "CMS ";
Tsmiclose. size = new system. Drawing. Size (98, 22 );
Tsmiclose. Text = "disabled ";
Tsmiclose. Click + = new system. eventhandler (this. tsmiclose_click );
//
// Tsmiclose
//
CMS. Items. addrange (new system. Windows. Forms. toolstripitem [] {
TsmiClose });
Cms. Name = "tsmiClose ";
Cms. Size = new System. Drawing. Size (99, 26 );
This. TabPageContextMenuStrip = cms;
}
Private void tsmiClose_Click (object sender, EventArgs e)
{
This. Close ();
}
}
}