Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2025-10

a bug in MouseToCell?

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

duilio foschi

in a TDBGrid, I add the following code:

procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X,
 Y: Integer);
var
   aCol, aRow: Integer;
begin
   DBGrid1.MouseToCell(X, Y, aCol, aRow);
   if (aRow = 0) and (aCol >= 0) and (aCol < DBGrid1.Columns.Count) then
   begin
      DBGrid1.Hint := inttostr(acol);
      DBGrid1.ShowHint := True;
   end
   else
   begin
      DBGrid1.Hint := '';
      DBGrid1.ShowHint := False;
   end;
end;

When the mouse in column 0, the hint says '1'.

See:
https://ibb.co/tTxGwbzp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20251024/f655b3aa/attachment.htm>

Reply by email

gabor
to duilio foschi

The MouseToCell method comes from TCustomGrid, the ancestor of TDBGrid, so this is not a bug but a desired effect.
If you want to get the correct column, see the MouseToRecordOffset method: https://lazarus-ccr.sourceforge.io/docs/lcl/dbgrids/tcustomdbgrid.mousetorecordoffset.html

Micha?.

W dniu 2025-10-24 o?22:36, duilio foschi via lazarus pisze:

Show quoted text 26 lines
in a TDBGrid, I add the following code: procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, ?Y: Integer); var ? ?aCol, aRow: Integer; begin ? ?DBGrid1.MouseToCell(X, Y, aCol, aRow); ? ?if (aRow = 0) and (aCol >= 0) and (aCol < DBGrid1.Columns.Count) then ? ?begin ? ? ? DBGrid1.Hint := inttostr(acol); ? ? ? DBGrid1.ShowHint := True; ? ?end ? ?else ? ?begin ? ? ? DBGrid1.Hint := ''; ? ? ? DBGrid1.ShowHint := False; ? ?end; end; When the mouse in column 0, the hint says '1'. See: https://ibb.co/tTxGwbzp <https://ibb.co/tTxGwbzp>

Reply by email

Martin Frb
to duilio foschi: in a TDBGrid, I add the following code: procedure TForm1.DBGrid1MouseMove(Sender:…
duilio foschi wrote
When the mouse in column 0, the hint says '1'.

What about the fixed column with the "arrow" symbol? Isn't that 0? I don't know, I haven't checked.

Actually not sure how fixed columns are handled by that at all....

And more:
I don't recall all the details. But there were some changes/fixes in 4.99 related to that (not sure if they got merged to 4-fixes) See
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681 https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41700 And maybe more than mentioned in those 2 issues

search the gitlog for grid in May/June 2025

Reply by email

duilio foschi
to Martin Frb

I did some further research. Yes. Here column 0 is meant to be the one with the arrow sign (the one that shows the current row).

No bug.

Thank you

Il Sab 25 Ott 2025, 01:00 Martin Frb via lazarus <

Show quoted text 26 lines
ha scritto: On 24/10/2025 22:36, duilio foschi via lazarus wrote: > When the mouse in column 0, the hint says '1'. > What about the fixed column with the "arrow" symbol? Isn't that 0? I don't know, I haven't checked. Actually not sure how fixed columns are handled by that at all.... And more: I don't recall all the details. But there were some changes/fixes in 4.99 related to that (not sure if they got merged to 4-fixes) See https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681 https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41700 And maybe more than mentioned in those 2 issues search the gitlog for grid in May/June 2025 -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20251025/8d9f3fa7/attachment.htm>

Reply by email

Bart
to Martin Frb: What about the fixed column with the "arrow" symbol? Isn't that 0? I don't know, I…
Show quoted text 7 lines
And more: I don't recall all the details. But there were some changes/fixes in 4.99 related to that (not sure if they got merged to 4-fixes) See https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681 https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41700 And maybe more than mentioned in those 2 issues

They were not merged yet, and the merge request has been removed upon request by Jesus.
Further more Jesus wants to revert all those changes: see the discussion in https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681 Apparently having the mouse over a fixed _ROW_ makes it logical to name the gridzone _gzFixedCol_ and vice versa.
I disagree (obviously).
To be continued...

Bart

Reply by email

Luca Olivetti
to Bart

El 25/10/25 a les 10:56, Bart via lazarus ha escrit:

Further more Jesus wants to revert all those changes: see the discussion in https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681

Interesting. AFAIR I have never used CellToGridZone or MouseToGridZone, but I'd say that to avoid confusion the name of the zone should match the property defining the zone, i.e. FixedRows for the FixedRows property and FixedCols for the FixedCols property. But then I'm also used to (digital) inputs named "Emergency stop pressed" that are active when the emergency stop button is *not* pressed and "Safety door open" that are active when the safety door is closed (which in fact generates no end of confusion and safety issues).

Bye

Luca Olivetti Tel. +34 935883004 Ext. 3010 https://wetron.es https://wecobots.com

Reply by email

Flávio Etrusco
to Luca Olivetti

On Mon, Oct 27, 2025, 13:00 Luca Olivetti via lazarus <

Show quoted text 15 lines
wrote: El 25/10/25 a les 10:56, Bart via lazarus ha escrit: > Further more Jesus wants to revert all those changes: see the > discussion in https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41681 Interesting. AFAIR I have never used CellToGridZone or MouseToGridZone, but I'd say that to avoid confusion the name of the zone should match the property defining the zone, i.e. FixedRows for the FixedRows property and FixedCols for the FixedCols property. (...) -- Luca Olivetti

I agree with Lucas (and Bart and Martin).
WRT gzFixedCells I think I'd rather call it FixedCorner or FixedRowCols... -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20251027/ae6666d0/attachment.htm>

Reply by email

Bart
to Luca Olivetti: El 25/10/25 a les 10:56, Bart via lazarus ha escrit: Interesting. AFAIR I have never used…
Interesting. AFAIR I have never used CellToGridZone or MouseToGridZone, but I'd say that to avoid confusion the name of the zone should match the property defining the zone, i.e. FixedRows for the FixedRows property and FixedCols for the FixedCols property.

Feel free to give that feedback in the associated bugreport. It's exactly what my arguments were, and it's good to have feedback about this (the naming) being intuitive or not.

Bart

Reply by email