窗体闪烁
那城 2010-01-04 07:16:47 procedure showMDIForm( var AForm: TForm; AFormClass: TFormClass; AParent: TComponent);
var
I:Integer;
CurrForm : TForm;
begin
try
for i:= 0 to MainForm.MDIChildCount - 1 do
begin
CurrForm := MainForm.MDIChildren[i];
if CurrForm <> nil then
begin
CurrForm.Close;
CurrForm.Free;
end;
end;
//screen.Cursor := crHourGlass;
//lockwindowupdate(MainForm.handle);
aform:=nil;
try
LockWindowUpdate(GetDeskTopWindow);//锁定屏幕
aform:=aFormClass.Create(AParent);
// aform.FormStyle := fsNormal ;
//AForm.Visible := False;
//AForm.Position:=poMainFormCenter;
//LockWindowUpdate(AForm.Handle);
//SendMessage(AForm.Handle,WM_SETREDRAW,0,0);
finally
Screen.Cursor:=crDefault;
end;
try
LockWindowUpdate(GetDeskTopWindow);//
aform.WindowState :=wsMaximized;
//SendMessage(AForm.Handle,WM_SETREDRAW,1,0);
//RedrawWindow(AForm.Handle, nil, 0, RDW_ERASE or RDW_FRAME or RDW_INVALIDATE or RDW_ALLCHILDREN);
finally
LockWindowUpdate(0);//
end;
AForm.DoubleBuffered := True;
aform.show;
//MainForm.pnl1.Visible:=False;
//screen.Cursor := crDefault;
// LockWindowUpdate(0);
except
end;
end;