Visual studio 2015 如何在VisualStudio扩展包中隐藏标题栏

Visual studio 2015 如何在VisualStudio扩展包中隐藏标题栏,visual-studio-2015,vs-extensibility,Visual Studio 2015,Vs Extensibility,我正在创建一个VisualStudio扩展包。我正在尝试创建一个没有标题栏的工具窗口。 我不希望最小化、最大化或关闭按钮可用。我想通过按钮来处理关闭等功能 在我的用户控制范围内。有人能告诉我这是否可行吗?编辑:这适用于标准windows窗体。从理论上讲,它应该与VS可扩展性相同。。。。我会自己检查一下,但我目前没有安装扩展性工具 要完全隐藏框架,可以单击表单,转到表单选项,然后设置FormBorderStyle=None。从这里,您可以在表单本身上设计替换栏 只是一个警告:一旦你这样做了,你会发

我正在创建一个VisualStudio扩展包。我正在尝试创建一个没有标题栏的工具窗口。 我不希望最小化、最大化或关闭按钮可用。我想通过按钮来处理关闭等功能
在我的用户控制范围内。有人能告诉我这是否可行吗?

编辑:这适用于标准windows窗体。从理论上讲,它应该与VS可扩展性相同。。。。我会自己检查一下,但我目前没有安装扩展性工具

要完全隐藏框架,可以单击表单,转到表单选项,然后设置
FormBorderStyle=None
。从这里,您可以在表单本身上设计替换栏

只是一个警告:一旦你这样做了,你会发现你不能在屏幕上移动你的窗口。若要修复此问题,请将此代码应用于替换标题栏的任何控件

命名空间声明:

使用系统图

全局变量:

//Declare the variables that allow you to drag the form
private bool dragging;
private Point dragAt = Point.Empty;
方法

//This method is called when you have locked onto a control so you can drag the form around
public void Pick(Control control, int x, int y)
{
    dragging = true;
    dragAt = new Point(x, y);
    control.Capture = true;
}

//This method is called when you release the control
public void Drop(Control control)
{
    dragging = false;
    control.Capture = false;
}
控件处理程序——这些处理程序在您用来保存新工具栏的任何控件上运行。或者,您可以创建这些通用处理程序(而不是
ObjectName\u WhatItHandles
您可以将它们命名为
WhatItHandlesHandler
),并将它们分配给触发
MouseDown
MouseUp
MouseMove
事件的任何控件

//This method is called whenever the mouse button is held down
private void TableLayoutPanel1_MouseDown(object sender, MouseEventArgs e)
{
    Pick((Control)sender, e.X, e.Y);
}

//This method is called whenever the mouse button is released
private void TableLayoutPanel1_MouseUp(object sender, MouseEventArgs e)
{
    Drop((Control)sender);
}

//This method is called when you move the mouse around
private void TableLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
    if (dragging)
    {
        Left = e.X + Left - dragAt.X;
        Top = e.Y + Top - dragAt.Y;
    }
    else dragAt = new Point(e.X, e.Y);
}