在mdichild和正常情况下,有一个孩子形式切换



我当前正在尝试重新创建Visual Studio的对接面板/形式。我想将同一系统应用于另一个项目以处理不同的窗口视图,但首先我想重新创建它。

到目前为止,我一直在Mainform和Null之间切换Mdiparent属性,但无法重新创建Visual Studio中看到的平稳过渡。总是很笨拙,一半的时间我发现鼠标up事件我将开关绑在很少工作(我当前正在使用位置更改事件)。

要移动表单,我一直在使用我发现的那种方便的代码块;

 #region Form Movement
    public const int WM_NCLBUTTONDOWN = 0xA1;
    public const int HT_CAPTION = 0x2;
    [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
    [System.Runtime.InteropServices.DllImportAttribute("user32.dll")]
    public static extern bool ReleaseCapture();
    private void MoveForm()
    {
        ReleaseCapture();
        SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
    }
    #endregion

要处理码头/拆卸,我正在使用此代码;

    private void DockToMain()
    {
        Point f = Form1.Main.PointToClient(this.Location);
        Point newP = new Point(f.X - 25, f.Y - 51);
        try { this.MdiParent = Form1.Main; } catch { }
        this.Location = newP;
    }
    private void UnDockFromMain()
    {
        Point f = Form1.Main.PointToScreen(this.Location);
        Point newP = new Point(f.X + 25, f.Y + 51);
        try { this.MdiParent = null; } catch { }
        this.Location = newP;
    }

有没有办法在Winforms中重新创建码头面板/表单?我在这里什至在正确的轨道上,还是有更好的方法我看不到?

只是为了回答这个问题,意志是完全正确的。我以某种方式把它做到了,但是它太故意了,无法使用。只需切换到WPF(从Winforms中跳起来并不难),然后使用XceedSoftware的"扩展WPF工具包"的Avalon Dock控件

相关内容

最新更新