//下列代码在memo控件中正常发挥功能
procedure TForm1.RichEdit1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  lc:Longint;
  CharPos:Word;
begin
  lc:= SendMessage(RichEdit1.handle,EM_CHARFROMPOS,0,x+(y shl 16));//向文本框传递消息EN_CHARFROMPOS  CharPos:=Word(lc);  
end;//'Access violation at address 74DA95B3 in module 'RICHED.dll.''
有解决办法吗?

解决方案 »

  1.   

    没人搭理啊。伤心……我于用的是delphi7,大家分别用两个控件的mousedwon事件试一下。
      

  2.   

    Access Violation(非法访问),General Protection Fault(一般保护性错误)或者Invalid Page Fault(无效页面错误),虽然说法不一样,但本质上总是由同一种错误引起的。Access Violation常常在计算机用户运行的程序试图存取未被指定使用的存储区时遇到。 
    Access violation at address <十六进制值> 
    in module <应用程序名> 
    Read of address <十六进制值> “Access violation at address 00000000.Read of adress 00000000.意思是:在地址 00000000 存取违反,禁止对地址00000000的读取 出现access violation at address 00000000. read of address 00000000.原因是:没有运行服务端软件,所以客户机会提示"Access violation at address 00000000, read of address 0000000",开启服务端程序或检查网线即可解决。 另外,可能出现这个问题的原因是因为你是在WINRAR的窗口中运行程序,而程序又找不到主要文件引起的。 解决方法:)~~ 
    尝试用兼容方式运行该程序.右键点击图标——属性——兼容型——选中“以兼容方式运行该程序”——下面的选框中可以选择以95、98、NT4.0或2000模式来运行。推荐选择98试试看。
      

  3.   

    Richedi一般使用rtf格式。memo使用纯文本。两者冲突。使用粘贴板试试。
      

  4.   

    to (jingtuzhong):听了你的分析,却是增了不少知识。但这不是最终的解决方法吧。
    to (猎狐):粘贴板具体怎么使用?下面我把代码全部贴出,希望有什么办法改进一下以便在richedit中也能运行: {函数IsSparetor用于判定一个字符是否为分隔符}
    function TForm1.IsSeparetor(ch: Char): Boolean;
    begin
       IsSeparetor :=False;  if   ch   in   [' ',',','.', '?',#13,#10]   then
     
       IsSeparetor:= True  ;
    end;{函数GetWord用于读取鼠标所在位置的单词}
    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[i]) Then
           begin
            pos1:= i + 1;
            break
           end;
     {向后搜寻当前单词的结束位置}
       For i:= pos To pos2 do
         If IsSeparetor(st[i])Then
           begin
            pos2:= i - 1;
            break
           end;
    {截取pos1-pos2间的字符,以构成一个单词}
        if pos1<=pos2 then
          begin
            For i:= pos1 To pos2 do
            w:=w+st[i];
            GetWord:= '单词:'+w
          end ;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
       memo1.Lines.Add('THis si a test!');  
    end;
    procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
      lc:Longint;
      CharPos:Word;
    begin
    {向文本框传递消息EN_CHARFROMPOS}
      lc:= SendMessage(Memo1.handle,EM_CHARFROMPOS,0,x+(y shl 16));{取得鼠标位于第几个字符上}
      CharPos:=Word(lc);
    {显示我们所点取的单词}
         caption:= GetWord(CharPos);
    end;