【问题标题】:Delphi Tokyo FMX - Access Violation after selecting date from TDateEdit when using StylesDelphi Tokyo FMX - 使用样式时从 TDateEdit 选择日期后访问冲突
【发布时间】:2017-11-01 09:39:08
【问题描述】:

在使用样式时,从 TDateEdit 选择器中单击选定日期时出现访问冲突。

首先,您必须从 (DELPHI)/Redist/styles/fmx 文件夹中的样式示例中选择任何样式到 TStyleBook 组件。

然后运行程序并从 Windows 上的 datepicker 中选择任何日期

单位:“untDateTime.pas”

unit untDateTime;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.DateTimeCtrls, FMX.Styles.Objects, FMX.Ani, FMX.StdCtrls, FMX.Effects,
  FMX.Filter.Effects;

type
  TForm1 = class(TForm)
    StyleBook1: TStyleBook;
    DateEdit2: TDateEdit;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.fmx}

end.

图片来自设计和错误:

【问题讨论】:

  • 在质量门户提交错误报告

标签: delphi styles firemonkey


【解决方案1】:

现在在东京 NeedStyleLookup 实际上是免费的控件样式资源。当您单击弹出窗口中的 Date 时,TCalendar 会使 IsOpen := False 弹出和 popupform 杀死 TCalendar 的样式资源 - FPopupForm.RemoveObject(Self);

我看不到通过制作自定义 TDateEdit 来解决此问题的优雅方法。 只能提供一种快速解决方案。我不知道其他单位(FMX.PhoneDialer.iOS.pas、FMX.PhoneDialer.iOS.pas)的 ISO 和 ANDROID 情况。对于其他人,您可以在项目中复制 FMX.Pickers.Default.pas 并将其重命名,例如 FMX.Pickers.DefaultFix.pas

现在添加此更改:

procedure TPopupDateTimePicker.DoDateSelected(Sender: TObject);
begin
  TThread.CreateAnonymousThread(
    procedure
    begin
      TThread.Synchronize(nil,
        procedure
        begin
          IsOpen := False;
        end);
    end).Start;

//  IsOpen := False;
end;

procedure TPopupDateTimePicker.DoDayClick(Sender: TObject);
begin
  DoDateChanged(Parent);

  TThread.CreateAnonymousThread(
    procedure
    begin
      TThread.Synchronize(nil,
        procedure
        begin
          IsOpen := False;
        end);
    end).Start;

//  IsOpen := False;
end;

并添加

initialization
{$IFNDEF IOS OR ANDROID}
  UnregisterPickersService;
  RegisterPickersService;
{$ENDIF}
end.

【讨论】:

  • 柏林版本中也出现了这种 AV 行为。我必须在 Windows 版本上禁用样书才能没有这个问题。
【解决方案2】:

这对我有用:

procedure TMAIN.AppException(Sender: TObject; E: Exception);
begin
  //--- DO NOTHING ---
  //Application.ShowException(E);
  //Application.Terminate;
end;

procedure TMAIN.DateEdit2Change(Sender: TObject);
begin
Application.OnException := AppException;
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多