unit StrGrid;
interface
Uses Vcl.Grids, System.Types, Classes;
type
TAfterPaintEvent = procedure (Sender: TObject; SelectedCellArea: TRect) of object;
TStrGrid = class(TStringGrid)
private
FOnAfterPaint: TAfterPaintEvent;
protected
procedure Paint; override;
Public
property InplaceEditor;
end;
// GetWindowRect(Handle: HWND; Var LPRECT: TRect);
procedure Register;
implementation
{ TStrGrid }
procedure TStrGrid.Paint;
Var SelectedCellArea: TRect;
GRect: TGridRect;
begin
inherited;
GRect.TopLeft := Selection.TopLeft;
GRect.Right := 0; GRect.Bottom := 0;
GridRectToScreenRect(GRect, SelectedCellArea, False);
If Assigned(FOnAfterPaint) then FOnAfterPaint(Self, SelectedCellArea);
end;
procedure Register;
begin
RegisterComponents('Grids', [TStrGrid]);
end;
end.
I wrote this to obtain the first selected cell
I installed it making a Grids.dpk file and put it under 'Grid' but the
'Grid' is not visible in the IDE?
its like something basic I've done wrong?
Just wondering what’s wrong with using TStringGrid.OnDrawCell, which would necessitate the above in the first place?
TStringGrid is now way better than Delphi 7 TStringGrid
OnDrawCell and selection done before the cell Selection is so much nicer
But trying to get my way around to install my own TControl
Windows uses the top left of the screen as the datum
Delphi uses the top left of the form canvas as the datum - correct
and
SGrid.MouseToCell(X, Y, ACol, ARow);
Rect := SGrid.CellRect(ACol, ARow);
are the tools to do that with
I’m just finding my way around 1st so I can put a plan together