Solved

CRichEditView OnDraw

Posted on 1998-09-01
3
628 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 62
Hibernate methods 2 71
post4 challenge 28 100
Increment column based of a FK 8 21
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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