1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| const
WM_MESSAGE = WM_USER + 1;
type
TSG_InplaceEditor = class helper for TStringGrid
public
{ Déclarations publiques }
function GetInplaceEditor(): TInplaceEdit;
end;
type
TForm1 = class(TForm)
StringGrid: TStringGrid;
procedure StringGridGetEditText(Sender: TObject; ACol, ARow: Integer; var Value: string);
private
{ Déclarations privées }
procedure OnMyMessage(var Msg: TMessage); message WM_MESSAGE;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TSG_InplaceEditor.GetInplaceEditor: TInplaceEdit;
begin
Result := InplaceEditor;
end;
procedure TForm1.OnMyMessage(var Msg: TMessage);
var
InplaceEdit: TInplaceEdit;
begin
InplaceEdit := StringGrid.GetInplaceEditor();
if Assigned(InplaceEdit) then // Exemple :
InplaceEdit.SelStart := InplaceEdit.GetTextLen;
end;
procedure TForm1.StringGridGetEditText(Sender: TObject; ACol, ARow: Integer; var Value: string);
begin
PostMessage(Handle, WM_MESSAGE, 0, 0);
end; |
Partager