.NET隐藏标题栏,但保留边框 [英] .NET hide titlebar but keep border
问题描述
我想知道如何隐藏表单的标题栏,但保留原始边框,例如Dropbox:
I was wondering how to hide the titlebar of a form but keep the original border, like e.g Dropbox does:
预先感谢!
推荐答案
将 FormBorderStyle
设置为 FormBorderStyle.Sizable
或 FormBorderStyle.SizableToolWindow
并将 Text
设置为空字符串,以及 ControlBox
到 false
Set FormBorderStyle
to FormBorderStyle.Sizable
or FormBorderStyle.SizableToolWindow
and set Text
to an empty string, and ControlBox
to false
请注意, c $ c> FixedToolWindow 不起作用,它将删除边框。如果您不希望它变大,请使用 SizableToolWindow
并将其添加到表单的代码隐藏中(添加两种语言,因为您没有同时指定和标记问题) :
Note that FixedToolWindow
won't work, it will remove the border. If you don't want it to be sizable, use SizableToolWindow
and add this to the form's codebehind (adding both languages since you don't specify and tagged the question with both):
在vb.net中:
Protected Overrides Sub WndProc(ByRef message As Message)
If message.Msg = &H84 Then ' WM_NCHITTEST
message.Result = CType(1, IntPtr)
Return
End If
MyBase.WndProc(message)
End Sub
在C#中结束
protected override void WndProc(ref Message message)
{
if (message.Msg == 0x0084) // WM_NCHITTEST
message.Result = (IntPtr)1;
else base.WndProc(ref message);
}
这篇关于.NET隐藏标题栏,但保留边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!