Solved

Disable copying, cutting and pasting in my richedit

Posted on 2007-03-21
3
252 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
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now