2006. október 17., kedd
How to avoid flicker when moving or sizing a MDI child form (2)
Problem/Question/Abstract:
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:
{ ...}
TForm1 = class(TForm)
private
fLockClientUpdateCount: Integer;
public
constructor Create(aOwner: TComponent); override;
procedure LockClientUpdate;
procedure UnlockClientUpdate;
end;
{ ... }
constructor TForm1.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
fLockClientUpdateCount := 0;
end;
procedure TForm1.LockClientUpdate;
begin
if fLockClientUpdateCount = 0 then
SendMessage(ClientHandle, WM_SETREDRAW, 0, 0);
Inc(fLockClientUpdateCount);
end;
procedure TForm1.UnlockClientUpdate;
begin
Dec(fLockClientUpdateCount);
if fLockClientUpdateCount = 0 then
begin
SendMessage(ClientHandle, WM_SETREDRAW, 1, 0);
RedrawWindow(ClientHandle, nil, 0, RDW_FRAME or RDW_INVALIDATE or
RDW_ALLCHILDREN or RDW_NOINTERNALPAINT)
end;
end;
Now, simply call LockClientUpdate and UnlockClientUpdate instead of LockWindowUpdate.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése