Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 带FireDAC的VCL错误&;CmdExecMode=amCancelDialog?_Delphi_Vcl_Firedac - Fatal编程技术网

Delphi 带FireDAC的VCL错误&;CmdExecMode=amCancelDialog?

Delphi 带FireDAC的VCL错误&;CmdExecMode=amCancelDialog?,delphi,vcl,firedac,Delphi,Vcl,Firedac,当CmdExecMode设置为amCancelDialog并执行某一组操作时,我在FireDAC中遇到了一个奇怪的问题。问题是,执行这些操作会使应用程序处于一种非常奇怪的状态,在这种状态下,单击表单上的任意位置或使用TAB键将引发“无法聚焦已禁用或不可见的窗口”异常。此状态还使鼠标光标在例如悬停在TEdit上时不会改变 出现异常是因为应用程序试图将焦点设置为不再可见的表单中的TStringGrid 以下事件序列触发此奇怪状态: -使用ShowModal打开表单 -双击打开表单中的TStringG

当CmdExecMode设置为amCancelDialog并执行某一组操作时,我在FireDAC中遇到了一个奇怪的问题。问题是,执行这些操作会使应用程序处于一种非常奇怪的状态,在这种状态下,单击表单上的任意位置或使用TAB键将引发“无法聚焦已禁用或不可见的窗口”异常。此状态还使鼠标光标在例如悬停在TEdit上时不会改变

出现异常是因为应用程序试图将焦点设置为不再可见的表单中的TStringGrid

以下事件序列触发此奇怪状态:
-使用ShowModal打开表单
-双击打开表单中的TStringGrid,设置ModalResult
-打开查询

这是某种VCL错误还是这里真正发生的事情?有办法摆脱这种状态吗

Delphi版本是XE7


异常的堆栈跟踪:

:75d1b727 KERNELBASE.RaiseException + 0x58
Vcl.Forms.TCustomForm.SetFocus
Vcl.Forms.TCustomForm.FocusControl(???)
Vcl.Controls.TWinControl.SetFocus
Vcl.Grids.TCustomGrid.MouseDown(mbLeft,[ssLeft],100,40)
Vcl.Controls.TControl.DoMouseDown((513, (), 1, (), 100, 40, (), (100, 40), (), 0),mbLeft,[])
Vcl.Controls.TControl.WMLButtonDown((513, (), 1, (), 100, 40, (), (100, 40), (), 0))
Vcl.Grids.TCustomGrid.WMLButtonDown(???)
Vcl.Controls.TControl.WndProc((513, 1, 2621540, 0, 1, 0, (), 100, 40, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((513, 1, 2621540, 0, 1, 0, (), 100, 40, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(6885476,513,1,2621540)
Vcl.Forms.TApplication.ProcessMessage(???)
:005efbe2 TCustomForm.FocusControl + $66
代码:


unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.PG,
  FireDAC.Phys.PGDef, FireDAC.VCLUI.Async, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.Comp.UI, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    FDConnection1: TFDConnection;
    FDGUIxAsyncExecuteDialog1: TFDGUIxAsyncExecuteDialog;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    query: TFDQuery;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Unit2;

procedure TForm1.Button1Click(Sender: TObject);
begin
   Form2.ShowModal;
   query.Open('SELECT * FROM table');
   query.Close;
end;

end.
unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    StringGrid1: TStringGrid;
    procedure StringGrid1DblClick(Sender: TObject);
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.StringGrid1DblClick(Sender: TObject);
begin
   ModalResult := mrOk;
end;

end.