WindowStyle=None 的不可调整大小、有边框的 WPF 窗口
基本上,我需要一个如下图所示的窗口: http://screenshots.thex9 .net/2010-05-31_2132.png
(不可调整大小,但保留玻璃边框)
我已设法使其与 Windows 窗体一起使用,但我需要使用 WPF。为了让它在 Windows 窗体中工作,我使用了以下代码:
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x84 /* WM_NCHITTEST */)
{
m.Result = (IntPtr)1;
return;
}
base.WndProc(ref m);
}
这完全符合我的要求,但我找不到 WPF 等效项。我用 WPF 实现的最接近结果导致窗口忽略任何鼠标输入。
任何帮助将不胜感激:)
Basically, I need a window to look like the following image: http://screenshots.thex9.net/2010-05-31_2132.png
(Is NOT resizeable, yet retains the glass border)
I've managed to get it working with Windows Forms, but I need to be using WPF. To get it working in Windows Forms, I used the following code:
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x84 /* WM_NCHITTEST */)
{
m.Result = (IntPtr)1;
return;
}
base.WndProc(ref m);
}
This does exactly what I want it to, but I can't find a WPF-equivalent. The closest I've managed to get with WPF caused the Window to ignore any mouse input.
Any help would be hugely appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个非常简单的解决方案是在窗口构造函数中将每个窗口的最小和最大大小设置为彼此相等并设置为固定数字。就像这样:
这样用户就不能改变窗口的宽度和高度。您还必须设置“WindowStyle=None”属性才能获取玻璃边框。
A very simple solution is to set the Min and Max size of each window equal to each other and to a fix number in the window constructor. just like this:
this way the user can not change the width and height of the window. also you must set the "WindowStyle=None" property in order the get the glass border.
您需要为消息循环添加一个钩子:
You need to add a hook for the message loop :