Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when form resizing starts and stops?

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.

like image 648
Jerry Dodge Avatar asked May 18 '12 00:05

Jerry Dodge


1 Answers

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;
like image 81
TLama Avatar answered Nov 14 '22 06:11

TLama