Solved

CRichEditView OnDraw

Posted on 1998-09-01
3
627 Views
Last Modified: 2013-11-20
I've created an application using app wizard in Visual C++ 5.0. It's a MDI Using CRichEditView as its view class.  I want to intercept keyboard messages and modify them before they appear on the screen.  I also want to format the text so the line spacing is something other than 1.
2 questions:
Where does the keyboard message handling occure?  I can't find it anywhere.  I can map an OnKeydown function, but it seems to be called after the message has been processed elsewhere.
 
Where does the actualy screen drawing occur.  If I knew these things, I could customize the application to do what I need.

Thanks.
0
Comment
Question by:tseph
3 Comments
 

Author Comment

by:tseph
ID: 1321592
Adjusted points to 190
0
 

Expert Comment

by:blueoak
ID: 1321593
The WM_KEYUP and WM_KEYDOWN (as well as the WM_SYSKEYDOWN, WM_SYSKEYUP) messages are sent to the window with the current "input focus" (a result of windows getting the handle of the window under the cursor). I dont' know if these will help anything. I don't know if these messages are processed somewhere else first.

As for the spacing between letters, you need to make a call to

int CDC::SetTextCharacterExtra(int);
This spacing is added (in form of pixels for MM_TEXT. The other mapping modes either are or need to be converted to pixels) to EVERY character including blanks and will achieve the S p a c i n g  E f f e c t.
There's also a
int CDC::GetTextCharacterExtra(); to get the current spacing value.

As for understanding where the screen drawing occurs. I'm not sure if you are referring to which functions are used to update the screen or how to output the text yourself. Either way, it can be a lengthy answer and could be better understood if read in a tutorial or a good book on MFC programming.
0
 
LVL 1

Accepted Solution

by:
rlarner earned 190 total points
ID: 1321594
Rich edit windows are special windows, since the control is not in the standard comctrl library.  This means that the usual ways of working with them don't work, including key filtering.

For the keypress filtering: try using GetRichEditCtrl().SetEventMask(EN_MSGFILTER).  This should cause the edit control to send your view a WM_NOTIFY message that has the key pressed information, which you can then modify.  (Look at the documentation on EN_MSGFILTER for more description)  Or, you can set all the rich edit control's text to protected, and then the control will send an EN_PROTECTED message to allow you to deal with the modification.  The protected method will allow you to capture ANY modification of the text.

For the spacing: I assume you mean line spacing (e.g. double), and not character spacing (blueoak's suggestion).  This is a little more difficult.  You may try to switch the rich edit view's base windows class to the rich edit 2.0 window, which allows you to do a LOT more formatting (including line spacing).  However, this is not very well supported in the MFC classes.  Search search.microsoft.com and www.dejanews.com for "richedit 2.0" for more information.  MSDN has a lot of information about 2.0 and 1.0 rich edit controls, in the "SDK Documentation/Platform SDK/User InterfaceServices/Controls/Rich Edit Controls" section.
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

Title # Comments Views Activity
Perl Awk Need Help 3 109
not able to insert into temp table 68 157
sumDigits challenge 9 124
Is there a simple front-end menu system. 9 71
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

17 Experts available now in Live!

Get 1:1 Help Now