zoukankan      html  css  js  c++  java
  • FMX App的Application的事件(各种手机的全局按键)

    直接上代码,还有条经验就是SetApplicationEventHandler可注册多个事件方法。

    unit Unit6;

    interface

    uses
      System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
      FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.Platform;

    type
      TForm6 = class(TForm)
        Memo1: TMemo;
        procedure FormCreate(Sender: TObject);
      private
        function HandleAppEvent(AAppEvent: TApplicationEvent;
          AContext: TObject): Boolean;
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form6: TForm6;

    implementation

    {$R *.fmx}


    procedure TForm6.FormCreate(Sender: TObject);
    var
      SvcEvents: IFMXApplicationEventService;
    begin
      if TPlatformServices.Current.SupportsPlatformService
        (IFMXApplicationEventService, IInterface(SvcEvents))
      then
        SvcEvents.SetApplicationEventHandler(HandleAppEvent);

    end;

    function TForm6.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
    var
      astate: string;
    begin
      case AAppEvent of
        TApplicationEvent.FinishedLaunching:
          astate := 'FinishedLaunching';
        TApplicationEvent.BecameActive:
          astate := 'BecameActive';
        TApplicationEvent.WillBecomeInactive:
          astate := 'WillBecomeInactive';
        TApplicationEvent.EnteredBackground:
          astate := 'EnteredBackground';
        TApplicationEvent.WillBecomeForeground:
          astate := 'WillBecomeForeground';
        TApplicationEvent.WillTerminate:
          astate := 'WillTerminate';
        TApplicationEvent.LowMemory:
          astate := 'LowMemory';
        TApplicationEvent.TimeChange:
          astate := 'TimeChange';
        TApplicationEvent.OpenURL:
          astate := 'OpenURL';
      end;
      Self.Memo1.Lines.Add(astate);
      Result := true;
    end;

    end.

    http://blog.sina.com.cn/s/blog_44fa172f0102vwr2.html

  • 相关阅读:
    MapReduce的工作机制
    1023. Have Fun with Numbers (20)
    Javascript MVC 学习笔记(二) 控制器和状态
    Chapter 1 Securing Your Server and Network(5):使用SSL加密会话
    《MySQL必知必会学习笔记》:子查询
    C# 打开指定的目录 记住路径中 / 与 的使用方法
    JAVA虚拟机、Dalvik虚拟机和ART虚拟机简要对照
    应届生面试准备之道
    一致性hash
    android 关于listview scrollview 底部 控件无法显示的两个解决方案
  • 原文地址:https://www.cnblogs.com/findumars/p/6480119.html
Copyright © 2011-2022 走看看