QQ中文件传输结束后,会在richedi中显示:打开文件、打开目录。这样的超链接,不知道是用什么方法实现的。

解决方案 »

  1.   

    http://tech.ddvip.com/2006-07/11542802086475.html
      

  2.   

    各位大哥,这些功能都有现成的。我是说要实现特定文字的链接。如:打开文件,上面这些可以通过sendmessage可以实现。面明rxrichedit里面现成就提供这几个功能
      

  3.   

    还是自己用word做一个连接,然后保存为rtf,文件,用ue打开,看看里面的连接格式,然后自己直接按照格式用流写入吧
      

  4.   

    procedure TedForm.DoSetLink;
    var i,j,n,m:integer;
        s,t:string;
    const sLink='<ilink:';
    begin
      Editor.SelStart := 0;
      i:=Editor.FindText(sLink,Editor.SelStart,Editor.GetTextLen-Editor.SelStart,[]);
      if i<1 then exit;  Screen.Cursor := crHourGlass;
      Editor.Perform(WM_SETREDRAW,0,0);
      Editor.OnChange := nil;
      Editor.OnSelectionChange := nil;
      try
        Editor.SelLength := 0;
        while i>0 do
          begin
            Application.ProcessMessages;
            Editor.SelStart := i;
            j:=Editor.FindText('>',Editor.SelStart,Editor.GetTextLen-Editor.SelStart,[]);
            Editor.SelLength := j-i;
            s:=Editor.SelText;
            t:=s;
            delete(t,1,pos(':',t));        if IsDigit(t) then  //是esoid
              begin
                n:=strtoint(t);
                with eofm do
                for m:=0 to TreeView.Items.Count -1 do
                if Integer(TreeView.Items[m].Data) = n then
                  begin
                    t:=TreeView.Items[m].Text;
                    break;
                  end;
              end else
            if pos('.',t)>0 then t:=ExtractFileName(t);        m:=Editor.SelStart - lengthex(t);
            if m < 0 then m := 0;
            Editor.SelStart := m;
            Editor.SelLength := lengthex(t+s)+1;
            Editor.SelAttributes.Link := true;        Editor.SelStart := i;
            Editor.SelLength := lengthex(s)+1;
            Editor.SelAttributes.Hidden := true;
            i:=Editor.FindText(sLink,j,Editor.GetTextLen-j,[]);
          end;
      finally
        Screen.Cursor := crDefault;
        Editor.Perform(WM_SETREDRAW,0,0);
        Editor.OnChange := EditorChange;
        Editor.OnSelectionChange := EditorChange;
        Editor.Perform(WM_SETREDRAW,-1,0);
        Editor.Refresh;
      end;
    end;
    procedure TedForm.EditorURLClick(Sender: TObject; const URLText: String;
      Button: TMouseButton);
    var s:string;
        i,j:integer;
        hlp:boolean;
    begin
      s:=URLText;
      hlp:=pos('help.chm',lowercase(s))>0;
      if hlp then begin MainForm.helpAction.Execute; exit; end;
      if length(s)<8 then exit;
      if s[length(s)]=' ' then delete(s,length(s),1);
      if (pos('://',s)>0) or (pos('mailto:',s)>0) then
        begin
          URLink(PChar(s));
          exit;
        end;
      i:=pos('<',s);
      if i=0 then exit;  i:=pos(':',s); if i>0 then delete(s,1,i);
      i:=pos('<',s); if i>0 then delete(s,1,pos(':',s));
      delete(s,length(s),1);
      if not IsDigit(s) then
        begin
          URLink(PChar(s));
          exit;
        end;
      j:=strtoint(s);
      with eofm do
      for i:=0 to TreeView.Items.Count -1 do
      if Integer(TreeView.Items[i].Data) = j then
        begin
          TreeView.Selected := TreeView.Items[i];
          break;
        end;
    end;
      

  5.   

    直接有第三方控件可以使用,点击链接可以打开Web超链接、自定义窗体等。
      

  6.   

    打开WEB超链接现在是可以做到的,主要是做象WORD一样能够链接到文件,打开链接就直接打开文件
      

  7.   

    呵呵
    我在RXRICHEDIT里做的,完全可以像WORD一样链接到文件,甚至是数据库里的数据或者其它任何东西。
    算了,不说了
      

  8.   

    procedure TedForm.InsertHyperlinktoLocalFile1Click(Sender: TObject);
    var fn,s,t:string;
        i,j:integer;
    begin
      fn:=OpenDialogFiles(true,sOpen,InitPath,'*.*');
      if not FileExists(fn) then exit;
      Editor.SelLength := 0;
      i:=Editor.SelStart;
      s:=ExtractFileName(fn);
      t:=format(sLinkStr,[fn]);
      Editor.SelText := s+t;
      Editor.SelStart := i;
      Editor.SelLength := lengthex(s+t);
      j:=i+Editor.SelLength + 1;
      CurrText.Link := true;
      Editor.SelLength := 0;
      Editor.SelStart := Editor.FindText(t,i,length(s+t),[]);
      Editor.SelLength := lengthex(t);
      CurrText.Hidden := true;     
      Editor.SelLength := 0;
      Editor.SelStart := j;
    end;主要代码都贴给你了.
    因为与我的程序相关,你可能需要自己调试一下代码.
    基本原理就是将选定文字设置为link,并将链接内容隐藏起来,在onurlclick事件里自己将链接内容分离出来.
      

  9.   

    不好意思,我有点笨,对里面的几个参数不明白。
    1、CurrText,在Rxrichedit中不知怎么实现。
    2、sLinkStr怎么表示。
    谢谢先
      

  10.   

    CurrText可以看rxrichedit的DEMO.sLinkStr:
    形如<ilink:xxxx>
    你自己定义.
      

  11.   

    没有DEMO了,真急死人了,能不能发个DEMO给学生啊
      

  12.   

    有没有delphi贰仟零壹拾的版本?