如何删除WPF窗口的非客户区,而无需使用ALLOWTRANSPARENCY [英] How to remove the non client area of a WPF window without using AllowTransparency

查看:295
本文介绍了如何删除WPF窗口的非客户区,而无需使用ALLOWTRANSPARENCY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的WPF自定义窗口删除调整的边界。 我已经发现,我必须处理WM_NCCALCSIZE消息并返回0。 去除所述边界,对齐窗口到窗口的左上角。 的问题是,通过这样做,客户区增大和WPF的根控制没有。 这造成在窗口的左侧和底部黑边,我想摆脱。

I would like to remove the resizing border from my WPF custom window. I already found that I have to handle the WM_NCCALCSIZE message and return 0. That removes the border and aligns the window to the top left corner of the window. The problem is that by doing so, the client area increases and the WPF root control doesn't. That creates black edges on the left and bottom sides of the window that I would like to get rid of.

我用VS2010 C#的Windows XP,并想这下在Windows XP和Windows 7。工作

I'm using VS2010 C# Windows XP and would like this to work under both Windows XP and Windows 7.

在此先感谢。

编辑: 我发现是什么原因造成黑边,他们身后的窗口。 目前看来,这个问题是不是占据整个窗口的窗口的根元素。当我将其利润率为负值它绘制了黑色区域。显然布局传递是确定和期望的尺寸是相同的窗口,但呈现大小是不同的。

I found out what is causing the black edges, they are the window behind. Now it seems that the problem is with the root element of the window not occupying the whole window. When I set its margin to negative values it draws over the black area. Apparently the layout pass is ok and the desired size is the same as the window but the render size is different.

我还发现,整个问题可以通过从窗口样式删除WS_THICKFRAME来解决。与该问题是,才启用时WS_THICKFRAME用于调整大小功能。我使用WM_NCHITTEST做调整大小,如果窗口知道它不具备调整的边界,它会关闭它的大小调整功能。

I also found out that the whole problem could be solved by removing WS_THICKFRAME from the window style. The problem with that is the resizing functionality that is enabled only when WS_THICKFRAME is used. I'm using WM_NCHITTEST to do the resizing and if the window knows it doesn't have a resizing border, it will shutdown its resizing functionality.

我想提出的根元素占据整个窗口消除的黑色窗口背景或可选择地使本机大小调整功能,而厚厚的框架。

I would like to make the root element occupy the whole window to eliminate the black window background or alternatively enable the native resizing functionality without the thick frame.

感谢。

推荐答案

我发现了黑色区域的原因。 看来,code口用别人提出通过用所述布局传递的框架,因此根元素的正确大小不知何故搞乱使黑色区域。 我处理了WM_NCCALCSIZE在另一个项目和它的工作就像一个魅力。

I found the reason for that black area. It appears that the code I was using that someone else made was causing the black area by somehow messing with the layout pass of the framework and therefore the correct size of the root element. I handled the WM_NCCALCSIZE in another project and it worked like a charm.

在所有这一切,虽然我找到空闲的方式来创建所有的原窗口功能的自定义窗口,我决定用标准的窗口微软所提供的,这样我的程序将与Windows未来的兼容性。

After all of that, although I found the idle way to create a custom window with all of the original window functionality, I decided to use the standard window the Microsoft has to offer so that my program will have future compatibility with windows.

如果有人想在code或WPF窗口定制帮助,他们可以在这里发表意见,我会帮助,这样至少我所有的研究不会白费。

If someone would like the code or help with WPF window customization they can comment here and I will help so that at least all of my research won't go in vain.

感谢您的阅读。

这篇关于如何删除WPF窗口的非客户区,而无需使用ALLOWTRANSPARENCY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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