大悟还俗

邮箱 key_ok@qq.com 我的收集 http://pan.baidu.com/share/home?uk=1177427271
posts - 236, comments - 8, trackbacks - 0, articles - 0
  新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

RichEdit选中文字右键菜单的实现

Posted on 2013-10-09 13:15 大悟还俗 阅读(...) 评论(...) 编辑 收藏
procedure TForm1.RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
var
 vPoint: TPoint;
begin
 if Button <> mbRight then Exit;
 vPoint := Point(X, Y);
 X := SendMessage(RichEdit1.Handle, EM_CHARFROMPOS,0,
    Integer(@vPoint)) and $0000FFFF;// 得到鼠标点击字符位置
 if (X >= RichEdit1.SelStart) and
    (X <= RichEdit1.SelStart + RichEdit1.SelLength) then
    ShowMessage(RichEdit1.SelText);
end;
View Code