FMX.Controls.TPopup.OnAniTimer
Delphi
property OnAniTimer: TNotifyEvent read FOnAniTimer write SetOnAniTimer;
C++
__property System::Classes::TNotifyEvent OnAniTimer = {read=FOnAniTimer, write=SetOnAniTimer};
プロパティ
種類 | 可視性 | ソース | ユニット | 親 |
---|---|---|---|---|
event | public | FMX.Controls.pas FMX.Controls.hpp |
FMX.Controls | TPopup |
説明
TCustomPopupForm カスタム アニメーション実行の間に、一定時間毎に発生します。
OnAniTimer イベントは、AniDuration の時間の間に一定時間ごとに発生する一方、カスタム アニメーションは、現在の TPopup ポップアップ ウィンドウが現れてから閉じるまでに実行されます。
OnAniTimer イベント ハンドラを記述すると、現在のポップアップ ウィンドウが現れてから閉じられるまで、アニメーションの機能を提供します。 AniDuration は、アニメーションの時間を秒数で定義します。
TPopup ウィンドウを表示させるには、IsOpen プロパティを True
に設定し、Popup メソッドを呼び出します。TPopup ウィンドウをレンダリングすると、所有者のフォームは、CreatePopupForm を呼び出し、PopupForm プロパティに格納されている TCustomPopupForm ポップアップ フォームのインスタンスを作成します。TPopup ウィンドウに配置されているすべてのビジュアル コンポーネントは、PopupForm ポップアップ フォームに作成されている ContentControl に格納されている点に注意してください。
OnAniTimer イベント ハンドラは、次のように宣言されている TNotifyEvent 型です:
TNotifyEvent = procedure(Sender: TObject) of object;
このため、次の例での Sender
パラメータは、TCustomPopupForm にキャストできます。TPopup ウィンドウを開き、閉じるアニメーションを実装する次の例において、これが OnAniTimer
イベントの AniTimeProc
イベント ハンドラで、どのように使用されているか見てみましょう:
type
TForm1 = class(TForm)
Button1: TButton;
Popup1: TPopup;
Button2: TButton;
Rectangle1: TRectangle;
procedure FormCreate(Sender: TObject);
public
T: TDateTime;
procedure AniTimeProc(Sender: TObject);
end;
var
Form1: TForm1;
implementation
procedure TForm1.AniTimeProc(Sender: TObject);
begin
Button1.Text := FloatToStr(RoundTo((Now - T) * 86400{SecPerDay}, -2));
TCustomPopupForm(Sender).ContentControl.Opacity := TCustomPopupForm(Sender).AniPosition;
TCustomPopupForm(Sender).Left := Self.Left + Round(100 * TCustomPopupForm(Sender).AniPosition);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
T := Now;
Popup1.Popup;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Popup1.AniDuration := 4;
Popup1.OnAniTimer := AniTimeProc;
end;
end.
OnAniTimer は TCustomPopupForm の AniPosition や他のプロパティも使用できる点に留意してください。