有没有办法改变插入符号在像素中的位置?
每次我移动鼠标的时候,我都想移动护理处。
像这样:
Onmousemove: MoveCaretPos(X,Y);
发布于 2011-06-01 15:14:43
不可以,您不能在特定点设置插入符号的位置,而必须将插入符号设置在字符位置。为此,必须使用EM_CHARFROMPOS消息检索最接近指定点的字符,然后设置返回给SelStart属性的值。
检查此示例
procedure TForm1.RichEdit1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
APoint : TPoint;
Index : Integer;
begin
APoint := Point(X, Y);
Index := SendMessage(TRichEdit(Sender).Handle,EM_CHARFROMPOS, 0, Integer(@APoint));
if Index<0 then Exit;
TRichEdit(Sender).SelStart:=Index;
end;https://stackoverflow.com/questions/6197305
复制相似问题