如何检测表单调整大小的开始和结束? [英] How to detect when form resizing starts and stops?

查看:151
本文介绍了如何检测表单调整大小的开始和结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个相当大的形式的实时绘图。当用户调整窗体大小时,我不想在尺寸变化的情况下,直到用户释放鼠标按钮,直到调整大小。一旦用户完成了表单的大小调整,我该如何检测这个并且只调整我的渲染的大小?因为现在,如果我使用我的表单的 OnResize 事件,它将不断重新渲染鼠标移动的每个像素的所有内容。



我已经尝试了鼠标向下/向上的事件并跟踪这一点,但是在调整窗体大小时这些事件不会被调用。

解决方案

要检测移动或调整大小已经开始,请抓住 WM_ENTERSIZEMOVE 讯息。一旦用户点击窗口的标题栏或大小边框(使窗口进入移动或调整大小的循环),它将被发送到窗口。



要检测移动或大小调整已完成,请抓住 WM_EXITSIZEMOVE 消息。一旦用户释放窗口的标题栏或大小边框(使窗口退出移动或调整大小的循环),它将被发送到窗口。



您可以捕获任何一个他们通过在表单级别声明(并实现)他们:

  procedure WMEnterSizeMove(var Message:TMessage);消息WM_ENTERSIZEMOVE; 
procedure WMExitSizeMove(var Message:TMessage);消息WM_EXITSIZEMOVE;


I'm working with some real-time drawing on a sizable form. When the user resizes the form, I do not want to apply size change to my graphics rendering until the user has released the mouse button, thus resizing is finished. How do I detect this and only resize my rendering once the user has finished resizing the form? Because right now, if I use the OnResize event of my form, it will constantly re-render everything for every pixel the mouse has moved.

I have tried the mouse down/up events and tracking this, but these events aren't called when the form is being resized.

解决方案

To detect the moving or sizing has started, catch the WM_ENTERSIZEMOVE message. It's being sent to a window once the user clicks the window's title bar or sizing border (what makes the window enter the moving or sizing loop).

To detect the moving or sizing has finished, catch the WM_EXITSIZEMOVE message. It's being sent to a window once the user release the window's title bar or sizing border (what makes the window exit the moving or sizing loop).

You can catch either of them by declaring (and implementing) them at the form level:

procedure WMEnterSizeMove(var Message: TMessage); message WM_ENTERSIZEMOVE;
procedure WMExitSizeMove(var Message: TMessage); message WM_EXITSIZEMOVE;

这篇关于如何检测表单调整大小的开始和结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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