delphi 中的一个简单的问题!!
在memo控件中怎么确定光标的位置?在第几行第几列?? 问题点数:20、回复次数:5Top
1 楼Liujc(阿聪)回复于 2002-04-13 10:25:54 得分 6
memo1.CaretPos.X //列
memo1.CaretPos.y //行Top
2 楼skill2002study(飘粼)回复于 2002-04-13 11:35:01 得分 8
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
linenum:longint;
charsbeforeline:longint;
begin
linenum:=sendmessage(memo1.Handle,em_linefromchar,memo1.SelStart,0); //em_linefromchar函数的使用
charsbeforeline:=sendmessage(memo1.Handle,em_lineindex,linenum,0); //em_lineindex函数的使用
form1.Label1.Caption:='Line'+inttostr(linenum+1);//显示行数;
form1.Label2.Caption:='Position'+inttostr((memo1.SelStart-charsbeforeline)+1);//显示列数
end;
end.Top
3 楼ihihonline(潇潇->戒烟)回复于 2002-04-13 11:51:41 得分 2
迟到一布Top
4 楼firetoucher(风焱)回复于 2002-04-13 15:25:59 得分 2
upTop
5 楼LuZhou(卢周)回复于 2002-04-13 15:45:15 得分 2
呵呵,看看delphi的sample吧Top




