Posisi Cursor

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
procedure Memo1Change(Sender: TObject);
procedure Memo1Click(Sender: TObject);
procedure Memo1Enter(Sender: TObject);
private
function Getlineindex : word;
function GetStrInsertIndex: word;
procedure GetCursorCoord;

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

function TForm1.Getlineindex : word;
begin
result :=SendMessage(Memo1.Handle,EM_LINEFROMCHAR,memo1.SelStart,0);
end;
function TForm1.GetStrInsertIndex : word;
begin
GetStrInsertIndex:=Memo1.SelStart-SendMessage(Memo1.Handle,EM_LINEINDEX,Getlineindex,0);
end;
{$R *.dfm}

procedure TForm1.GetCursorCoord;
var
Lineindex : word;
linechar : byte;
selst : word;
begin
selst:=Memo1.SelStart;
Lineindex:=Getlineindex;
linechar :=GetStrInsertIndex;
if Memo1.SelText > ” then
caption :=’text selected’ else
caption:=’Huruf ke ‘+IntToStr(linechar+1)+’,’+’baris ke ‘+IntToStr(Lineindex+1);
end;
procedure TForm1.Memo1Change(Sender: TObject);
begin
GetCursorCoord;
end;

procedure TForm1.Memo1Click(Sender: TObject);
begin
GetCursorCoord;
end;

procedure TForm1.Memo1Enter(Sender: TObject);
begin
GetCursorCoord;
end;

end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: