请问用鼠标从memo中取词该怎么实现?(100分)

  • 主题发起人 主题发起人 jhonguy
  • 开始时间 开始时间
J

jhonguy

Unregistered / Unconfirmed
GUEST, unregistred user!
就是把鼠标放再memo中,可以读出鼠标所在位置的单词,该怎么做?3thx
 
离线数据库中可能是有这方面的介绍
 
我有代码的哟,要不要?
 
检索LID :
673251
568573
175529
197467
518043
125314
够多了。自己看祝你好去。
 
to 张无忌
需要代码,3thx
jhon321@263.sina.com
 
unit UnitE2C;

interface

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

type
TForm1 = class(TForm)
Memo1: TMemo;
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
function IsSeparetor(ch:char):boolean;
function GetWord(pos:word):string;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

{ TForm1 }

function TForm1.GetWord(pos: word): string;
var
st:string;
pos1,pos2:word;
i:longint;
w:string;
begin
w:='';
pos1:=1;
getword:='';
st:=Memo1.lines.Text;
pos2:=length(st);
for i:=pos-1 downto 1 do
if IsSeparetor(st) then
begin
pos1:=i+1;
break
end;
for i:=pos to pos2 do
if IsSeparetor(st) then
begin
pos2:=i-1;
break;
end;
if pos1<=pos2 then
begin
for i:=pos1 to pos2 do
w:=w+st;
GetWord:='单词'+w;
end;
end;

function TForm1.IsSeparetor(ch: char): boolean;
begin
IsSeparetor:=false;
if ch in [' ',',','.','?',#10,#13] then
IsSeparetor:=true
end;

procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
lc:longint;
CharPos:word;
begin
lc:=SendMessage(Memo1.Handle,EM_CHARFROMPOS,0,x+(y shl 16));
charpos:=word(lc);
Memo1.Hint:=GetWord(charpos);
end;

end.
 
procedure TForm1.Memo1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if memo1.SelLength>0 then
showmessage(memo1.SelText);
end;
 
多人接受答案了。
 
需要原代码和取词技术,联系我 linsen633@sohu.com
 
后退
顶部