Drawing a background in a CRichEditCtrl

How can I put a bitmap background in a CRichEditCtrl while still allowing the control to draw its text normally over the background?
LVL 1
dabblerAsked:
Who is Participating?
 
mikeblasConnect With a Mentor Commented:
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

0
 
galkinCommented:
Try to override WM_ERASEBKGND message and paint background with your bitmap.
0
 
dabblerAuthor Commented:
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.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
gelbertCommented:
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
0
 
dabblerAuthor Commented:
Thanks, but I've tried that one too...no dice.
0
 
dabblerAuthor Commented:
Thanks!  What version of the COMCTL lib do I need for 2.0/3.0?
0
 
mikeblasCommented:
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
0
All Courses

From novice to tech pro — start learning today.