Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable Ctrl-A, Ctrl-C

Posted on 2009-05-07
5
Medium Priority
?
573 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
  • 2
4 Comments
 
LVL 48

Expert Comment

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

Wayne
0
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

824 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