Solved

Disable copying, cutting and pasting in my richedit

Posted on 2007-03-21
3
263 Views
Last Modified: 2010-04-05
Hi,

I got some code from EE to disable cutting, copying and pasting in my richedit, but the code
has a problem when caps lock was off, I made some change but it didn't work. I need a help.

Thanks

      if (ssCtrl in Shift) and ((key = Ord('V')) or (key = Ord('C')) or (key = Ord('X')) or
      (key = Ord('v')) or (key = Ord('c')) or (key = Ord('x'))) then
        if Clipboard.HasFormat(CF_TEXT) then begin
          ClipBoard.Clear;
          key := 0;
        end;

The code came from this page
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_10070659.html?sfQueryTermInfo=1+copi+disabl+past
0
Comment
Question by:hidrau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 18764897
this works for me with capslock both on and off

procedure TForm1.RichEdit1KeyDown(Sender: TObject; var Key: Word; Shift:
    TShiftState);
const FORBIDEN_KEYS = [Ord('c'), Ord('C'), Ord('v'), Ord('V'), Ord('x'), Ord('X')];
begin
  if (ssCtrl in Shift) and (Key in FORBIDEN_KEYS) then begin
   Clipboard.Clear;
  end;
end;

ziolko.
0
 
LVL 1

Author Comment

by:hidrau
ID: 18765471
are you sure of that?

Because I tested with a line in my richedit and I could copy and past it in the edit1.text.

0
 
LVL 1

Author Comment

by:hidrau
ID: 18765521
OK, puttin this line inside, it worked fine

  if (ssCtrl in Shift) and (Key in FORBIDEN_KEYS) then
   begin
     key:=0; --- here
     Clipboard.clear;
  end;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question