Solved

CRichEditView OnDraw

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
windows pagefile changed settings do not persist after a system restart 2 68
List out all word 7 224
EvenOdd challenge 10 83
Line meaning 9 77
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 (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

10 Experts available now in Live!

Get 1:1 Help Now