Einzelnen Beitrag anzeigen

Benutzerbild von Kedariodakon
Kedariodakon

Registriert seit: 10. Sep 2004
Ort: Mönchengladbach
833 Beiträge
 
Delphi 7 Enterprise
 
#5

Re: Problem mit AnimateWindow und Position

  Alt 15. Aug 2007, 15:08
Ich hab das eben so gelöst:
Delphi-Quellcode:
Unit uSplashScreen;

Interface

Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;

Type
  TfrmQSplashScreen = Class( TForm )
    Procedure FormCreate(Sender: TObject);
  Private
    { Private-Deklaration }
    FBlendEffect: Boolean;
  Protected
    { Protected-Deklaration }
    procedure CMShowingChanged(var Message: TMessage); Message CM_SHOWINGCHANGED;
  Public
    { Public-Deklaration }
    Property BlendEffect: Boolean Read FBlendEffect Write FBlendEffect;
  End;

Var frmQSplashScreen: TfrmQSplashScreen;

Implementation

{$R *.dfm}

Procedure TfrmQSplashScreen.FormCreate(Sender: TObject);
Begin
  BlendEffect := True;
End;

Procedure TfrmQSplashScreen.CMShowingChanged( Var Message: TMessage );
Var X: Integer;
    Y: Integer;
    CenterForm: TCustomForm;
Begin
  If BlendEffect Then Begin
    // Größenänderungen wurden aus "TCustomForm" übernommen
    If Showing Then Begin
      // Form wird angezeigt
      If ( Position = poScreenCenter) or ( ( Position = poMainFormCenter ) And ( FormStyle = fsMDIChild ) ) Then Begin
        If FormStyle = fsMDIChild Then Begin
          X := ( Application.MainForm.ClientWidth - Width ) Div 2;
          Y := ( Application.MainForm.ClientHeight - Height ) Div 2;
        End Else Begin
          X := ( Screen.Width - Width ) Div 2;
          Y := ( Screen.Height - Height ) Div 2;
        End;
        If X < 0 Then X := 0;
        If Y < 0 Then Y := 0;
        SetBounds( X, Y, Width, Height );
      End Else If Position In [ poMainFormCenter, poOwnerFormCenter ] Then Begin
        CenterForm := Application.MainForm;
        If ( Position = poOwnerFormCenter ) And (Owner Is TCustomForm ) Then CenterForm := TCustomForm( Owner );
        If Assigned( CenterForm ) Then Begin
          X := ( ( CenterForm.Width - Width ) Div 2 ) + CenterForm.Left;
          Y := ( ( CenterForm.Height - Height ) Div 2 ) + CenterForm.Top;
        End Else Begin
          X := ( Screen.Width - Width ) Div 2;
          Y := ( Screen.Height - Height ) Div 2;
        End;
        If X < 0 Then X := 0;
        If Y < 0 Then Y := 0;
        SetBounds(X, Y, Width, Height);
      End Else If Position = poDesktopCenter Then Begin
        If FormStyle = fsMDIChild Then Begin
          X := ( Application.MainForm.ClientWidth - Width ) Div 2;
          Y := ( Application.MainForm.ClientHeight - Height ) Div 2;
        End Else Begin
          X := ( Screen.DesktopWidth - Width ) Div 2;
          Y := ( Screen.DesktopHeight - Height ) Div 2;
        End;
        If X < 0 Then X := 0;
        If Y < 0 Then Y := 0;
        SetBounds(X, Y, Width, Height);
      End;
      // Form wird angezeigt
      AnimateWindow( Self.Handle, 1000, AW_BLEND );
    End Else Begin
      // Form wird versteckt
      AnimateWindow( Self.Handle, 1000, AW_BLEND or AW_HIDE );
    End;
  End;
  Inherited;
End;
Bye christian
Christian
  Mit Zitat antworten Zitat