Solved

Disable copying, cutting and pasting in my richedit

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LAN or WAN ? 11 92
C# code editing and collaboration 3 117
TEMBEDDEDWB how can i change its user agent ? 8 58
Is there a canned solution for a custom genealogy website 2 95
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

832 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