Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.

How to Get Current Memo Line Number

Author: admin | Category: Tips and Tricks, VCL

//This is how we can get Memo (TMemo) line number
//This example needs Memo1 (TMemo) and BUtton1 (TButton)
//By Clicking Button1, message box will show the memo line number where mouse cursor placed on the Memo
 
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  LineNumber:integer;
begin
  LineNumber := SendMessage(Memo1.Handle,EM_LINEFROMCHAR,-1,0);
  ShowMessage(inttostr(LineNumber));
end;
 
end.
 

Tags: