意外的tStringGrid.OnFixedCellClick触发tOpenDialog

JO *_*Gng 5 delphi topendialog tstringgrid

我在Windows 10上使用Delphi Berlin.我需要在基于tStringGrid的tForm上使用tOpenDialog.

当我双击一个与打开的对话框上的固定列或行重叠的文件onFixedCellClick事件在打开对话框消失后立即自动触发.在下图中,文件位于第一行的固定行的相同位置.

在此输入图像描述

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    OpenDialog1: TOpenDialog;
    procedure FormClick(Sender: TObject);
    procedure StringGrid1FixedCellClick(Sender: TObject; ACol, ARow: Integer);
    procedure FormCreate(Sender: TObject);
  end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  StringGrid1.Options := StringGrid1.Options + [goFixedColClick, goFixedRowClick];
end;

procedure TForm1.FormClick(Sender: TObject);
begin
  OpenDialog1.Execute;
end;

procedure TForm1.StringGrid1FixedCellClick(Sender: TObject; ACol, ARow: Integer);
begin
  Caption := '';
end;
Run Code Online (Sandbox Code Playgroud)

在大多数情况下,我可以通过移动对话框窗口或单击文件一次并单击打开按钮来处理此问题,但我无法保证将使用此功能的其他人会这样做.

是什么原因以及如何解决这个问题?

Ond*_*lle 5

我相信这是一个问题,如何TCustomGrid触发OnFixedCellClick鼠标向上消息(在其覆盖MouseUp方法中)的事件,而不检查是否有相应的鼠标按下消息(FHotTrackCell.Pressed).快速修复(如果你可以复制和修改Vcl.Grids):在柏林的4564号线上(在TCustomGrid.MouseUp方法中添加另一个要检查的条件,导致调用FixedCellClick):

if ... and FHotTrackCell.Pressed then
  FixedCellClick(Cell.X, Cell.Y);
Run Code Online (Sandbox Code Playgroud)

换句话说,FixedCellClick如果没有先前相应的鼠标按下鼠标,则不要调用.

  • 这确实需要QP报告 (4认同)
  • @DavidHeffernan [RSP-15758](https://quality.embarcadero.com/browse/RSP-15758) (2认同)