Author: Jonas Bilinkevicius
Has anyone found a way to prevent the Paint method from firing when you're in the
middle of resizing a form? In other words, is there some way to ghost the change
until the user actually releases the mouse button, instead of redrawing the form
constantly during the resize?
Answer:
You can revert to the way a window was resized in Win 3.1 - with a sizing frame and
a redraw only when the user let go of the mouse.
In your forms declaration you place this:
1 2 private3 {Private declarations}4 FDragFullWindowState: LongBool;
5 procedure WMEnterSizeMove(var msg: TMessage); message WM_ENTERSIZEMOVE;
6 procedure WMExitSizeMove(var msg: TMessage); message WM_EXITSIZEMOVE;
The implementation is like this:
1 2 private3 {Private declarations}4 FDragFullWindowState: LongBool;
5 procedure WMEnterSizeMove(var msg: TMessage); message WM_ENTERSIZEMOVE;
6 procedure WMExitSizeMove(var msg: TMessage); message WM_EXITSIZEMOVE;
The implementation is like this:
procedure TProdBuilderMainForm.WMEnterSizeMove(var msg: TMessage);
begin
SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, @FDragFullWindowState, 0);
if FDragFullWindowState then
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, Ord(False), nil, 0);
end;
procedure TProdBuilderMainForm.WMExitSizeMove(var msg: TMessage);
begin
if FDragFullWindowState then
SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, Ord(True), nil, 0);
end;