Solved

CRichEditView/CRichEditCtrl mesages

Posted on 1998-12-14
2
367 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now