问题描述
在Windows 7中,音量调音台的窗户有一个特定的风格,用厚厚的透明边框,但没有标题栏。我如何重新创建窗口样式在一个WinForms窗口?
我试着将文本的String.Empty,并控制盒为false,从而消除标题栏,但随后的边界也消失了:
form.Text =的String.Empty;
form.ControlBox = FALSE;
form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
对于一个固定大小的窗口,你还是应该用 FormBorderStyle.SizableToolWindow
,但你可以重写表单的的WndProc
忽略非客户命中测试(其用于切换到施胶游标):
保护覆盖无效的WndProc(参考消息消息)
{
const int的WM_NCHITTEST = 0×0084; 如果(message.Msg == WM_NCHITTEST)
返回; base.WndProc(参考消息);
}
如果你想真正执行的大小,你也可以设置的minimumSize
等于 MAXIMUMSIZE
的形式。
In Windows 7, the volume mixer windows has a specific style, with a thick, transparent border, but no title bar. How do i recreate that window style in a winforms window?
I tried setting Text to string.Empty, and ControlBox to false, which removes the titlebar, but then the border also disappears:
form.Text = string.Empty;
form.ControlBox = false;
form.FormBorderStyle = FormBorderStyle.SizableToolWindow;
For a fixed size window, you should still use FormBorderStyle.SizableToolWindow
, but you can override the form's WndProc
to ignore non-client hit tests (which are used to switch to the sizing cursors):
protected override void WndProc(ref Message message)
{
const int WM_NCHITTEST = 0x0084;
if (message.Msg == WM_NCHITTEST)
return;
base.WndProc(ref message);
}
If you want to really enforce the size, you could also set MinimumSize
equal to MaximumSize
on the form.
这篇关于如何创建带边框的形式,但没有标题栏? (如在Windows 7音量控制)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!