Solved

Disable Ctrl-A, Ctrl-C

Posted on 2009-05-07
5
556 Views
Last Modified: 2013-11-27
Hello Experts

I need to disable the ability of users to select and copy text in a Rich Text Control using Ctrl-A and Ctrl-C.

How do I go about this?

Many thanks
0
Comment
Question by:jindalee
[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
5 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24324840
Set the ShortCutsEnabled property to False.

Wayne
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24324900
To disable only Ctrl+A and Ctrl+C, you will need to intercept the KeyPresses.....
    Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown
 
        If e.Control Then
            If e.KeyCode = Keys.C Or e.KeyCode = Keys.A Then
                e.Handled = True
            End If
        End If
 
    End Sub

Open in new window

0
 
LVL 5

Expert Comment

by:rendaduiyan
ID: 24332705

        public bool PreFilterMessage(ref Message m)
        {
            if (m.Msg == WM_KEYDOWN)
            {
                return HandleKeys((Keys)((int)m.WParam) & Keys.KeyCode);
            }
            return false;
        }
        public bool HandleKeys(Keys keycode)
        {
            bool ret = true;
            switch (keycode)
            {
                case Keys.Alt | Keys.F4: this.Close();break;
                case Keys.Alt | Keys.N: MoveInList(Direction.FORWARD); break;
                case Keys.Alt | Keys.B: MoveInList(Direction.BACKWORD); break;
                //.........
                default: ret = false; break;
            }
            return ret;
        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:jindalee
ID: 31578957
Thank you webtubbs. Worked first time.

BTW. It is good to see a moderator remind a contributor that a submission should add value to the question and should also address specifics such as programming language. Too many times you see a question asking for a response in (e.g.) VB.Net only to find loads of answers in some other language.
0

Featured Post

Technology Partners: 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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

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