Solved

Disable copying, cutting and pasting in my richedit

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sending files from  idTcpServer Socket to idTcpClient 2 52
Interview question Javascript, database 12 90
Microsoft Access 97 and Delphi XE2 9 71
collection output issue 9 59
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The viewer will learn how to implement Singleton Design Pattern in Java.
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.

740 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