Author: Jonas Bilinkevicius
I have a MDI application which maximizes the client forms as they are created. On
Win9x I can stop the initial flash of the MDI child form being created by using
LockWindowUpdate(Handle). However on Win XP this code doesn't work as predicted.
The form updating is turned off, but the client form still draws its outline
briefly in the MDI client space. So, does anyone know how I can get round this on
Win XP?
Answer:
1 { ...}2 TForm1 = class(TForm)
3 private4 fLockClientUpdateCount: Integer;
5 public6 constructor Create(aOwner: TComponent); override;
7 procedure LockClientUpdate;
8 procedure UnlockClientUpdate;
9 end;
10 11 { ... }12 13 constructor TForm1.Create(aOwner: TComponent);
14 begin15 inherited Create(aOwner);
16 fLockClientUpdateCount := 0;
17 end;
18 19 procedure TForm1.LockClientUpdate;
20 begin21 if fLockClientUpdateCount = 0 then22 SendMessage(ClientHandle, WM_SETREDRAW, 0, 0);
23 Inc(fLockClientUpdateCount);
24 end;
25 26 procedure TForm1.UnlockClientUpdate;
27 begin28 Dec(fLockClientUpdateCount);
29 if fLockClientUpdateCount = 0 then30 begin31 SendMessage(ClientHandle, WM_SETREDRAW, 1, 0);
32 RedrawWindow(ClientHandle, nil, 0, RDW_FRAME or RDW_INVALIDATE or33 RDW_ALLCHILDREN or RDW_NOINTERNALPAINT)
34 end;
35 end;
Now, simply call LockClientUpdate and UnlockClientUpdate instead of LockWindowUpdate.