• 禁止TEdit或TMemo的“Ctrl+V”粘贴


    今天去About.com逛了逛,学到一点东西,记下来

    No "Paste" for you!
    To intercept any key combination for a TEdit (or TMemo or more generally TCustomEdit) you need to handle the OnKeyDown event.
    Put a TEdit named "Edit1" on a form (named "Form1"). Handle Edit1's OnKeyDown event as:

    uses Clipbrd, ...

    //disable CTRL + V ("Paste") :: handles Edit1.OnKeyDown
    procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState) ;
    begin
    if ((ssCtrl in Shift) AND (Key = ord('V'))) then
    begin
    if Clipboard.HasFormat(CF_TEXT) then ClipBoard.Clear;

    Edit1.SelText := '"Paste" DISABLED!';

    Key := 0;
    end;
    end;
    When the user presses the CTRL+V key combination while Edit1 has the input focus ... the code above will clear the clipboard and "paste" the '"Paste" DISABLED!' text into the edit control.
  • 相关阅读:
    c++静态变量和静态函数
    c++抽象类和纯虚函数
    二维矩阵的算法
    JS操作CSS样式
    DOM
    JavaScript学习
    CSS样式表介绍
    HTML 学习整理
    ADO.Net知识总结
    数据库表查询高级 触发器游标等
  • 原文地址:https://www.cnblogs.com/leonkin/p/2365983.html
Copyright © 2020-2023  润新知