2009. augusztus 15., szombat

Revert to Win 3.1 form resizing behaviour


Problem/Question/Abstract:

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:

private
        {Private declarations}
        FDragFullWindowState: LongBool;
        procedure WMEnterSizeMove(var msg: TMessage); message WM_ENTERSIZEMOVE;
        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;

Nincsenek megjegyzések:

Megjegyzés küldése