我想对用户通过复制的方法来输入的内容进行拦截处理。
怎么处理?

解决方案 »

  1.   

    在RichEdit的OnKeyDown事件中拦截Ctrl+V,获取剪贴板内容,然后粘贴到RichEdit光标处
      

  2.   

    重载之后截获消息! WM_KEYDOWNWM_PASTE 
    改写它们,就可以了
      

  3.   

    在RichEdit的OnKeyDown事件中拦截Ctrl+V,获取剪贴板内容,然后粘贴到RichEdit光标处
    ------------怎么拦截到Ctrl+V?
      

  4.   

    需要拦截的有Ctrl+V和Shift+Insert,它们都是粘贴的快捷键procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);
    begin
      if ((Key = ord('V')) and (ssCtrl in Shift))
        or ((Key = VK_INSERT) and (ssShift in Shift)) then
        Key := 0;
    end;
      

  5.   

    procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);
    begin
      if ((Key = ord('V')) and (ssCtrl in Shift))
        or ((Key = VK_INSERT) and (ssShift in Shift)) then
      begin
        Key := 0;
        ShowMessage(Clipboard.AsText);
      end;
    end;
      

  6.   

    需要引用Clipbrd单元uses Clipbrd;
      

  7.   

    那内容粘贴的内容如何获取呢?
    --------------------
    uses ClipbrdShowMessage(ClipBoard.AsText);//获取剪贴板内容
      

  8.   

    先判断一下是否为文本内容
    ifClipboard.HasFormat(CF_TEXT) then //判断剪贴板内容是否为文本
      ShowMessage(ClipBoard.AsText); //获取剪贴板内容
      

  9.   

    单纯截获ctrl+v是不行的,因为还可以通过鼠标右键或者shift+insert来粘贴
      

  10.   

    在OnKeyDown事件中写  
    ShiftState := KeyDataToShiftState(Message.KeyData);
      if(ssCtrl in ShiftState)and(Message.CharCode = 86)then
      begin
        lClipboard := TClipboard.Create;
        lstrValue := lClipboard.AsText;
      end;
      lstrValue为剪贴板中的内容
      

  11.   

    单纯截获ctrl+v是不行的,因为还可以通过鼠标右键或者shift+insert来粘贴---很有道理哦!!!
      

  12.   

    单纯截获ctrl+v是不行的,因为还可以通过鼠标右键或者shift+insert来粘贴---很有道理哦!!!
    1. 我前面就已经提到了Shift+Insert键的问题,并且给出的代码也处理了。2. Delphi中的RichEdit并不支持鼠标右键。