Showing posts with label wm_entersizemove. Show all posts
Showing posts with label wm_entersizemove. Show all posts

Friday, 21 June 2013

Delphi After Resize Event

Here is the way to handle what happens after a user has resized a form. This works fine for standard forms, but does not work for forms within a form.

procedure WMEXITSIZEMOVE(var Message: TMessage); message      WM_EXITSIZEMOVE;

procedure TForm1.WMEXITSIZEMOVE(var Message: TMessage);
begin
    ShowMessage('Just Resized');
end;

I would like to know if there is a way to capture an event when resizing a form in a form.

There is also a similar Windows message for when a user starts to resize a form, which is WM_ENTERSIZEMOVE.

Thursday, 22 November 2012

Screen flicker with gradient background

Recently I had a problem with flickering when resizing a screen due to a gradient background. The problem was mainly noticeable with control on top of the background. Below are a couple of snippets that might help.

First I tried this:

// Interface
procedure WMEraseBackground(var _message:TMessage); message WM_ERASEBKGND;

// Implementation
procedure TForm.WMEraseBackground(var _message: TMessage);
begin
    _message.Result := 1;
end;

This helped with the flicker on the gradient panel, but I noticed other issues with some other controls not painting correctly and a panel having a thicker border. Then I tried this:

// Interface
procedure WMEnterSizeMove(var Message:TWMMove); message WM_ENTERSIZEMOVE;
procedure WMExitSizeMove(var Message:TWMMove); message WM_EXITSIZEMOVE;

procedure TfrmMain.WMEnterSizeMove(var Message: TWMMove);
begin
    // Set controls to visible = false
end;

procedure TfrmMain.WMExitSizeMove(var Message: TWMMove);
begin
    // Set controls to visible = true
end;

Doing this really helped the other controls from flicking, when the user resizes the window the controls disappear and then reappear once the resize is complete.