Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Problem mit AnimateWindow und Position (https://www.delphipraxis.net/54402-problem-mit-animatewindow-und-position.html)

Helmi 3. Okt 2005 21:19


Problem mit AnimateWindow und Position
 
Hallo,

ich will folgendes benutzen:
Delphi-Quellcode:
AnimateWindow(Form2.Handle, 1200, AW_BLEND or AW_ACTIVATE);
Das geht auch ganz gut (ist ja von Microsoft :roll:), aber ich hab eine Form mit
Delphi-Quellcode:
Position = poScreenCenter
//im Objektinspektor eingestellt
das AnimateWindow hab ich ins OnShow der Form getan, aber jedesmal wenn nun das Fenster erscheint wird zuerst AnimateWindow ausgeführt bevor Position = poScreenCenter ausgeführt wird.
Das hat zur Folge, dass das Fenster irgendwo zu sehen ist - nur nicht in der Mitte des Bildschirmes.

Weiss jemand nen Rat dafür?

Flocke 3. Okt 2005 21:26

Re: Problem mit AnimateWindow und Position
 
Lass doch das poScreenCenter weg und verschieb das Fenster von Hand in die Bildschirmmitte (mit MoveWindow), bevor du AnimateWindow aufrufst.

Helmi 3. Okt 2005 21:30

Re: Problem mit AnimateWindow und Position
 
ja - das geht

nur find ich es schade dass man dann doch manuell eingreiffen muss.

Flocke 3. Okt 2005 21:34

Re: Problem mit AnimateWindow und Position
 
Machst du doch eh schon mit dem AnimateWindow! Schreib' dir 'ne Prozedur CenterAndBlendWindow die das macht, dann fällt's dir später gar nicht mehr auf.

Kedariodakon 15. Aug 2007 14:08

Re: Problem mit AnimateWindow und Position
 
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


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz