Solved

Disable copying, cutting and pasting in my richedit

Posted on 2007-03-21
3
266 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

623 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