Drawing a background in a CRichEditCtrl

Posted on 1998-03-24
Last Modified: 2013-11-19
How can I put a bitmap background in a CRichEditCtrl while still allowing the control to draw its text normally over the background?
Question by:dabbler
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

Expert Comment

ID: 1317188
Try to override WM_ERASEBKGND message and paint background with your bitmap.

Author Comment

ID: 1317189
I've already tried that, and it doesn't work.  The background gets painted with the bitmap, and is then covered over with a white background for the text.

Expert Comment

ID: 1317190
Just an idea. Try to create CStatic control with the same coordinates as your CRichEditCtrl and display whatever image you want inside it. this part is easy. Then create CRichEditCtrl with transparent background. Result should make an impression of CRichEditCtrl with image on background. Good luck
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1317191
Thanks, but I've tried that one dice.
LVL 11

Accepted Solution

mikeblas earned 250 total points
ID: 1317192
You'll not accomplish what you want with CRichEditCtrl (or CRichEditView) directly. MFC uses the Windows-supplied RichEdit Control 1.0, and that version of the control ignores the WS_EX_TRANSPARENT style and erases the background during WM_PAINT isntead of WM_ERASEBKGND.

You can sublcass CRichEditCtrl to use RichEdit 2.0 or 3.0 directly; you'll need to have your class initialize the correct DLL and create a control with the appropriate class name for the version of the control you want: it's all documented in the SDK.

Most of the messages you'll send to the control are the same no matter what versio no the control you're using, but most of the strucutres you get from or pass to the control are different. I can't remember if the newer versions of the control are backward-compatible with the old structures (I _think_ they are) but if you run into problems you'll have to avoid the MFC code and send raw messages yourself.

.B ekiM


Author Comment

ID: 1317193
Thanks!  What version of the COMCTL lib do I need for 2.0/3.0?
LVL 11

Expert Comment

ID: 1317194
The RichEdit control isn't supplied by COMCTL32.DLL; it's supplied by RICHEDIT.DLL.  You'll find plenty of information on the different DLL versions and the class names that invoke them in the SDK documentation.

.B ekiM

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 59
maxBlock challenge 30 151
Hibernate methods 2 88
centeredAverage challenge 8 188
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. …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
Suggested Courses

751 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