zoukankan      html  css  js  c++  java
  • delphi xe10 手机程序事件服务操作、退出键操作

    //程序事件服务操作
    var
      FMXApplicationEventService: IFMXApplicationEventService;
    begin
      if TPlatformServices.Current.SupportsPlatformService (IFMXApplicationEventService, IInterface(FMXApplicationEventService)) then 
        FMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent)
      else
         flag := false;
    end;
    
    function TForm1.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject)   : boolean; 
    begin 
      if flag = false then
        exit;
      case AAppEvent of
        TApplicationEvent.aeEnteredBackground:
          begin
              //当程序后台运行了
          end;
      end;
      Result := true;
    end;
    //退出键操作
    procedure TPForm.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
      Shift: TShiftState);
    begin
      if Key = vkHardwareBack then
      begin
        {$IFDEF ANDROID}
        MessageDlg('确认退出吗?', System.UITypes.TMsgDlgType.mtInformation,
        [
          System.UITypes.TMsgDlgBtn.mbYes,
          //System.UITypes.TMsgDlgBtn.mbNo,
          System.UITypes.TMsgDlgBtn.mbCancel
        ], 0, System.UITypes.TMsgDlgBtn.mbCancel,
        procedure(const AResult: TModalResult)
        begin
          if AResult = mrYES then
             MainActivity.finish; { 退出程序 }   // use FMX.Platform.Android
          end);
        {$ENDIF ANDROID}
        //close;
        Key := 0;
        exit;
      end;
    end;
  • 相关阅读:
    SpringIOC框架简单实现(注解实现)
    Spring前瞻----Java反射机制
    SpringMVC_前置知识
    SpringAOP_构造注入实现
    SpringAOP_设置注入实现
    SpringIOC-设置注入实现
    IDEA一些常用快捷键
    第一章计算机网络概述
    第二大章--数据链路层思维导图
    第一大章--1.2标准化工作
  • 原文地址:https://www.cnblogs.com/guorongtao/p/11137523.html
Copyright © 2011-2022 走看看