Solved

Disable Ctrl-A, Ctrl-C

Posted on 2009-05-07
5
562 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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