调整上右下角边框的窗口 [英] Resize borderless window on bottom right corner

查看:138
本文介绍了调整上右下角边框的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用户调整的右下角有一个无国界的窗口,就像我可以调整ComboBox控件的自动完成窗口。

I'd like the user to resize a borderless window on bottom right corner like I can resize the autocomplete window of the combobox control.

我找不到属性来配置表单的方式。

I cannot find the properties to configure a form that way.

也许有人可以帮助我的问题。

Maybe someone could help me on the problem.

图像可以在这里找到:

推荐答案

正确的方式来实现,这将是添加一个消息PROC处理器(通过重写<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.form.wndproc.aspx\"><$c$c>Form.WndProc例),表单和处理的<一个href=\"http://msdn.microsoft.com/en-us/library/ms645618%28VS.85%29.aspx\"><$c$c>WM_NCHITTEST信息。 (您可以找到该消息对 PInvoke.net C#的定义)尤其是,当您收到消息,如果计算点击测试是一个该地区的时候,你所指定的尺寸调整,如果是,则返回HTBOTTOMRIGHT。默认的窗口过程将完成剩下的给你,因为它会假定用户点击了窗口边框的右下角,即使你的窗口没有边框。

The proper way to achieve this would be to add a message proc handler (by overriding Form.WndProc for example) to your form and handle the WM_NCHITTEST message. (You can find the C# definition of that message on PInvoke.net) In particular, when you receive the message, calculate if the hit test is for a point in the region you've designated for resize and if it is, return HTBOTTOMRIGHT. The default window proc will do the rest for you, as it will assume that the user has clicked on the bottom right corner of the window border, even though your window has no border.

此形式给出需要的Win32互操作的teensy一点,但它会让你的大小调整看起来就像任何其他窗口大小调整。

This aproach requires a teensy bit of Win32 interop, but it'll make your resize look exactly like any other window resize.

最简单的办法是做的@benPearce说,把一个小组在角落里,用调节宽度/高度窗体大小。这将工作,但调整大小不会一帆风顺,尤其是在Vista和Win7基础,在全面重绘标准的移动禁用,调整大小,同时会尝试重绘每一步。

The easy way would be to do as @benPearce said and put a panel in the corner and adjust the form size using Width/Height. It's going to work, but the resize is not going to be smooth, especially on Vista and Win7 Basic, where full redraw is disabled on standard move and resize, while is going to attempt redraw on every step.

更新:在这两种方法,你将不得不弄清楚怎么也画夹子。你可以把标准夹持器的位图,例如。不过,考虑到您的窗体没有标题和边框,所以你并不一定与标准Windows的视觉效果卡住了,你可能会选择在什么snazzier。

Update: In both approaches you will have to figure out also how to paint the gripper. You can put a bitmap of the standard gripper, for example. Though, given that your form has no title and border so you are not necessarily stuck with the standard Windows visuals, you might opt in for something snazzier.

更新2 :如果你有一个覆盖整个窗口的控制,它会吃的形式鼠标消息。你必须以某种剪辑您想要使用的调整出控制的地方。您有几种选择来处理这样的:

Update 2: If you have a control that covers the whole window, it will eat the form mouse messages. You have to somehow clip the place you want to use for resizing out of that control. You have several options to deal with this:


  1. 调整控件,以便为调整大小握一定的空间。

  2. 扭捏控制区(通过量的区域属性),以排除调整大小的抓地力。

  3. 封面调整大小握面板,听它的MouseEnter消息,并设置形式捕获属性为true,这将导致所有的鼠标消息去了。 注意:你将不得不释放一次捕捉鼠标离开该调整大小后区完成

  1. Resize the control to make some space for the resizing grip.
  2. Tweak the control region (throug the Region property) to exclude the resizing grip.
  3. Cover the resizing grip a panel, listen to its MouseEnter message and set the form Capture property to true, which will cause all further mouse messages to go to it. Note: you will have to release the capture once the mouse leaves that region after the resize is finished.

我会建议去选择1为最简单的。方案3是最复杂的,需要对鼠标输入在Windows中是如何工作的贴心细节,所以我不会推荐它。方案2是一个很好的替代选择1,但你必须给它一个尝试,看看如何ListView控件将它的区域被调整的反应。

I would recommend to go for option 1 as the simplest. Option 3 is the most complex and would require intimate details on how mouse input works in Windows, so I wouldn't recommend it. Option 2 is a good alternative to option 1, but you'll have to give it a try to see how the ListView control would react to its region being tweaked.

这篇关于调整上右下角边框的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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