TMemo da kursor tuslarina bastikca event olusmasi

Başlatan z, 03 Haziran 2012, 17:21:04

z

Keypress eventi kursor tuslarindan etkilenmiyor. Kursor tuslari ile gezinildiginden nasil haberdar olabilirim?
Bana e^st de diyebilirsiniz.   www.cncdesigner.com


mozkan87

Keydown etkilenmiyormu? c++ builderda etkileniyorda.

z

Mouse tuslari etkilenmiyor. Sory sory sory:

Keypress eventine takilip kalmisim. Evet Keydown eventi olusuyormus.

Neyse asagida buldugum kodlar araya gitmesin: Memo da x,y koordinatlarini gosteriyor

http://www.esanu.name/delphi/Components/TMemo/Key%20press%20event%20on%20Tmemo%20and%20cursorarrow%20keys%20.html

unit Unit1;

interface
uses

  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type

  TForm1 = class(TForm)
    Memo1: TMemo;

  procedure Memo1Change(Sender: TObject);
  procedure Memo1Click(Sender: TObject);
  procedure Memo1Enter(Sender: TObject);
  procedure Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  procedure Memo1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
  procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  procedure Memo1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);

  private
  { Private declarations }

  Function GetLineIndex : Word;
  Function GetStrInsertIndex : Word;
  procedure GetCursorCoord;
  public
  { Public declarations }
  end;

var
  Form1: TForm1;
implementation
{$R *.DFM}

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;

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:='Col '+ inttostr(LineChar+1)+' , ' + 'Row '+ 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;

procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
        GetCursorCoord;
end;

procedure TForm1.Memo1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
        GetCursorCoord;
end;

procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
begin
        GetCursorCoord;
end;

procedure TForm1.Memo1MouseUp(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
begin
        GetCursorCoord;
end;

end.
Bana e^st de diyebilirsiniz.   www.cncdesigner.com