I want a winform library that allow users to merge several window into tabs of a single window, and split a tab into new window, just like the Google Chrom开发者_JAVA技巧e and debug/compile output windows in Visual Studio. Is there any library or sample project that provides such feature? Thanks for your help.
Avalon Dock is a library that allows you to build Visual Studio like GUI's. Unfortunately this is not a win forms library (wpf) however you can use it with winform controls.
http://avalondock.codeplex.com/
Use tab control
http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.tabpages.aspx
but for this you need to convert your form to user control and assign user control in tabs
You can implement your "windows" as user controls and place every user control onto a seperate tab page on a tab control. It doesn't matter what controls the user control itself contains. So it can for sure also contain a tab control that itself hosts other user controls.
To use a window inside a user control you can host it inside a panel using the following WinAPI methods:
[DllImport( "user32.dll" )]
public static extern bool ShowWindow( IntPtr hWnd, WindowShowStyle nCmdShow );
[DllImport( "user32.dll", SetLastError = true )]
public static extern IntPtr SetParent( IntPtr hWndChild, IntPtr hWndNewParent );
Example:
System.Diagnostics.Process externalProcess = new System.Diagnostics.Process( )
{
StartInfo = new System.Diagnostics.ProcessStartInfo( appToHost )
};
externalProcess.Start( );
externalProcess.WaitForInputIdle( );
if ( !externalProcess.HasExited )
{
ShowWindow( externalProcess.MainWindowHandle, ShowWindowStyle.Maximize );
SetParent( externalProcess.MainWindowHandle, panel.Handle );
}
This snippet adds the application located at appToHost
as a child control into the panel panel
.
Look at the DockPanel Suite. It will let you do what you describe, as well as dragging and docking behaviors if you want.
精彩评论