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
|
unit test_ln_col;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TfmMain = class(TForm)
sb: TStatusBar;
mo: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
procedure SetLineColumn(Sender: TObject; var Key: Word;
Shift: TShiftState);
end;
var
fmMain: TfmMain;
implementation
{$R *.dfm}
procedure TfmMain.SetLineColumn(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
ln, col : Integer;
begin
ln := SendMessage(mo.Handle, EM_LINEFROMCHAR, mo.SelStart, 0);
col := mo.Selstart - sendMessage(mo.Handle, EM_LINEINDEX, ln, 1);
sb.Panels[0].Text := 'Ln : ' + IntToStr(ln) + ' Col : ' + IntToStr(col);
end;
procedure TfmMain.FormCreate(Sender: TObject);
begin
mo.OnKeyDown := SetLineColumn;
end;
end. |
Partager