Solved

CRichEditView OnDraw

Posted on 1998-09-01
3
634 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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