Solved

CRichEditView/CRichEditCtrl mesages

Posted on 1998-12-14
2
377 Views
Last Modified: 2008-01-16
I have a CRichEditView/CRichEditCtrl application and need to 'grab' some of the 'EM_' messages i.e 'EM_SETPARAFORMAT' and EM_SETCHARFORMAT' before they are sent to the Rich Edit Control so I can modify the message data.

I have tried PreTranslateMessage() but these messages never seem to get there.

How do I intercept these messages.
0
Comment
Question by:bharkness
2 Comments
 
LVL 1

Expert Comment

by:andla
ID: 1180169
I don't know if this will help, but try the message loop before it sends the messages to the window:
while(GetMessage(0,0,0))
{
if(hWnd==hWndMyWindow)
{
//if msg == EM_BlaBla
//Do what you have to do with the message
}
}
0
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 1180170
Another way is to subclass the CRichEditCtrl. Construct a CRichEditCtrl derivate using
ClassWizard, and then use SubclassWindow() to dynamically subclass your existing control.
Now the 'PreTranslateMessage()' handler (of your subclassed window) should catch the
messages. If not (some messages MFC just won't let pass through) you need to use a
construct like this:

WNDPROC oldWndProc=wndRichEditCtrl->GetWindowLong(GWL_WNDPROC);
wndRichEditCtrl->SetWindowLong(GWL_WNDPROC, (LONG)MyWndProc);

.

LRESULT CALLBACK MyWndProc(UINT message, WPARAM wP, LPARAM lP)
{
  ...
  switch(message) {
    ...
    default:
       return (*oldWndProc)(message,wP,lP);
  }
  return 0;
}

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

828 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