.NET隐藏标题栏,但保留边框 [英] .NET hide titlebar but keep border

查看:89
本文介绍了.NET隐藏标题栏,但保留边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何隐藏表单的标题栏,但保留原始边框,例如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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆