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
Solved

Locking out CTRL-C on an MFC OCX wrapped rich edit control.

Posted on 2004-04-23
4
530 Views
Last Modified: 2013-11-20
I have written an OCX in MSV C++ Ver 6.00.  This control wraps a standard rich edit control.  My base class is cOleControl.

I want to disable the CTRL-C copy function so that information cannot be easily copied. The control is also read-only.  I have tried numerous Onxxxx methods to dectect a character of  ASCII 3 (ctrl-c) and not call the base class in this case.  I also did a check on the message pump function and did not pass the message along if it was a WM_CHAR with a character of 3.  I'm not that familiar with MFC, so I think I am lost.  Does the MFC object receive windows event first or last?  Any ideas on how to lock out ctrl-c in my case?

Thanks
0
Comment
Question by:rmichels
  • 2
4 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 125 total points
ID: 10904023
You should try to handle and suppress WM_COPY.
0
 
LVL 3

Author Comment

by:rmichels
ID: 10909755
I tried numerous ways to suppress WM_COPY.  What is the best way to capture the message?   Who gets the message first..MFC or the control I have created within my OCX.

Thanks
0
 
LVL 4

Accepted Solution

by:
r2far earned 125 total points
ID: 10912581
PreTranslateMessage() function recieves all events before they are dispatched to child controls and windows.


Here is an example.

BOOL CPEntry::PreTranslateMessage(MSG *pMsg)
{
   if( pMsg->hwnd==*this )
   {
      if( pMsg->message == WM_COPY )
      {
         // return TRUE says the message has been handled.
         return TRUE;
      }
   }

   return CMaskEntry::PreTranslateMessage(pMsg);
}



Hope this helps =)
0
 
LVL 3

Author Comment

by:rmichels
ID: 10912755
I accepted both of your answers and split the points as they put me on the right track..but...apparently an RTF control does not generate a WM_COPY.  The standard edit control does.  As I have this control read only and don't care about keyboard input I handled WM_CHAR, WM_KEYDOWN and WM_KEYUP in the pretranslate message function.

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 42
notReplace  challenge 53 142
fizzArray2 challenge 1 91
matchUp  challenge 9 115
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

829 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