StringGrid右击选中表格(发消息给句柄模拟点击,右键点击也是MouseDown)

时间:2025-01-15 08:37:14

顺便还把单元格给变了:

procedure TFGLGL.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
MousePos: TSmallPoint;
begin
if Button = mbRight then
begin
MousePos.x := x;
MousePos.y := y;
SendMessage(StringGrid1.Handle, WM_LBUTTONDOWN, , MAKELONG(x, y));
SendMessage(StringGrid1.Handle, WM_LBUTTONUP, , MAKELONG(x, y));
end;
end;

参考:http://www.cnblogs.com/lovemoon714/archive/2012/06/25/2561187.html