作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 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;
在大多数情况下,我可以通过移动对话框窗口或单击文件一次并单击打开按钮来处理此问题,但我不能保证其他使用此功能的人会这样做。
这个问题是什么原因以及如何解决?
最佳答案
我认为这是 TCustomGrid
如何在鼠标释放消息上触发其 OnFixedCellClick
事件(在其重写的 MouseUp
方法中)的问题而不检查是否有相应的鼠标按下消息(FHotTrackCell.Pressed
)。快速修复(如果您可以复制和修改Vcl.Grids
):在柏林的第4564行(在TCustomGrid.MouseUp
方法中添加另一个要检查的条件,导致调用到固定单元格点击):
if ... and FHotTrackCell.Pressed then
FixedCellClick(Cell.X, Cell.Y);
换句话说,如果鼠标松开之前没有相应的鼠标按下,则不要调用 FixedCellClick
。
关于delphi - tOpenDialog 后面意外触发 tStringGrid.OnFixedCellClick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39291978/
我在 Windows 10 上使用 Delphi Berlin。我需要在基于 tStringGrid 的 tForm 上使用 tOpenDialog。 当我双击与打开的对话框上的固定列或行重叠的文件时
我是一名优秀的程序员,十分优秀!