Einzelnen Beitrag anzeigen

Benutzerbild von Flocke
Flocke

Registriert seit: 9. Jun 2005
Ort: Unna
1.172 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#23

Re: Form ohne Animation maximieren

  Alt 12. Okt 2005, 18:13
SirThornberry hat Recht, in der VCL machen die wirklich so etwas (der Code ist jetzt nicht unbedingt Copyrightgefährdet, also poste ich ihn einfach mal):
Delphi-Quellcode:
function GetAnimation: Boolean;
var
  Info: TAnimationInfo;
begin
  Info.cbSize := SizeOf(TAnimationInfo);
  if SystemParametersInfo(SPI_GETANIMATION, SizeOf(Info), @Info, 0) then
    Result := Info.iMinAnimate <> 0 else
    Result := False;
end;

procedure SetAnimation(Value: Boolean);
var
  Info: TAnimationInfo;
begin
  Info.cbSize := SizeOf(TAnimationInfo);
  BOOL(Info.iMinAnimate) := Value;
  SystemParametersInfo(SPI_SETANIMATION, SizeOf(Info), @Info, 0);
end;

procedure CreateFormNoAnimate(Class: TComponentClass; var Reference);
var
  Animation: Boolean;
  Instance: TComponent;
begin
  Animation := GetAnimation;
  try
    if Animation then
      SetAnimation(False);

    Instance := TComponent(InstanceClass.NewInstance);
    TComponent(Reference) := Instance;
    try
      Instance.Create(Application);
    except
      TComponent(Reference) := nil;
      raise;
    end;
  finally
    if Animation then
      SetAnimation(True);
  end;
end;
... oder ohne Erzeugen halt so:

Delphi-Quellcode:
procedure WindowStateNoAnimate(Form: TCustomForm; State: TWindowState);
var
  Animation: Boolean;
begin
  Animation := GetAnimation;
  try
    if Animation then
      SetAnimation(False);

    Form.WindowState := State;
  finally
    if Animation then
      SetAnimation(True);
  end;
end;
Volker
Besucht meine Garage
Aktuell: RtfLabel 1.3d, PrintToFile 1.4
  Mit Zitat antworten Zitat