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
Solved

CRichEditView OnDraw

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 51
Error on moodle after upgrade 3 140
countEvens challenge 2 111
Window placement 17 85
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seveā€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

789 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