如何检测表单调整大小的开始和结束? [英] How to detect when form resizing starts and stops?
问题描述
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屋!