Hab's grad mal ausprobiert. Geht so nicht. aber so:
TDrawGrid.MouseToCell ist der Schlüssel.
Code: Alles auswählen
type
{ TForm1 }
TForm1 = class(TForm)
DrawGrid1: TDrawGrid;
MenuItem1: TMenuItem;
PopupMenu1: TPopupMenu;
procedure DrawGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
procedure DrawGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
var CanSelect: Boolean);
procedure MenuItem1Click(Sender: TObject);
procedure PopupMenu1Popup(Sender: TObject);
private
fCol, fRow : integer;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.PopupMenu1Popup(Sender: TObject);
var O : TObject;
mp : TPoint;
begin
mp := DrawGrid1.ScreenToClient(Mouse.CursorPos);
DrawGrid1.MouseToCell(mp.x, mp.y, fCol, fRow);
end;
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState);
begin
DrawGrid1.Canvas.TextOut(aRect.Left + 3, aRect.Top + 3, Format('%d / %d', [aRow, aCol]));
end;
procedure TForm1.DrawGrid1SelectCell(Sender: TObject; aCol, aRow: Integer;
var CanSelect: Boolean);
begin
end;
procedure TForm1.MenuItem1Click(Sender: TObject);
var s : string;
cs : boolean;
begin
DrawGrid1.Row := fRow;
DrawGrid1.Col := fCol;
cs := true;
DrawGrid1SelectCell(self, fCol, fRow, cs);
end;