Solved

Transparent RICHEDIT

Posted on 1998-02-18
10
1,070 Views
Last Modified: 2013-12-03
How do you make the background of a RICHEDIT control transparent? They've done it again. All the old methods, like making an EDIT control's background transparent, don't work. It's all different. Any suggestions?
0
Comment
Question by:tfrazier
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 2

Expert Comment

by:mnguyen021997
ID: 1411363
try trapping the WM_CTLCOLOREDIT message and returning the GetStockObject(NULL_BRUSH).  you will also need to re-rendering the individual strings while the user is deleting them.
0
 

Author Comment

by:tfrazier
ID: 1411364
Like I said, it's all different. The richedit control DOES NOT send WM_CTLCOLOREDIT to its parent (or any message like it). The old methods don't work. This is a new beast.
0
 
LVL 7

Expert Comment

by:galkin
ID: 1411365
Try to add WM_EX_TRANSPARENT extended style to control window. Also handle WM_ERASEBKGND and simply return TRUE.
0
 

Author Comment

by:tfrazier
ID: 1411366
Sorry, but no dice. The WM_ERASEBKGND message has been handy for things like this in the past, but not here. The
WM_EX_TRANSPARENT style is not intended for things like this and thus has no effect. Thanks for trying though. I'm beginning to think this can't be done. Somebody prove me wrong.
0
 
LVL 2

Expert Comment

by:mnguyen021997
ID: 1411367
a quick scan of mfc wizard allows you to trap the WM_CTLCOLOR message from rich edit control types.  it's not a notification message like EN_XXX thus the parent won't get it.  the richedit should be getting that message to itself, so try subclassing it and trap for that message.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:tfrazier
ID: 1411368
mnguyen, You are correct in that the class wizard allows you to put in a method to trap the WM_CTLCOLOR message, but this message is in fact never sent. I confirmed this with spy a few days ago. Thus the method is useless. The class that most closely wraps the actual RICHEDIT control, CRichEditCtrl does not include this ability to trap (of course, the message is never sent). I appreciate your help though and if you have any other ideas, please submit.


0
 
LVL 2

Expert Comment

by:anichini
ID: 1411369
While I think it may be impossible to have RichEdit be transparent while editing, it is possible to have it draw to a window transparently.

I implemented this a while back when I was writing a page layout program. The basic idea is to create the RichEdit control hidden as a child of your window. Then in your window's OnPaint, draw the RichEdit control in its position by using the EM_FORMATRANGE and passing it the HDC of your window. It gets tricky, though, since RichEdit is in TWIPS and you have to do a bunch of messy coordinate space/mapping mode gunk. The result is the RichEdit control draws its content to the window and you can do it in a way that is transparent. Then when the user wants to edit you show the richedit control and you get all the editing functions.

If this meets your needs I can paste the MFC code (converting it to pure Win32 shouldn't be too bad). If you have to have it transparent while editing, I think you may be out of luck.

0
 

Author Comment

by:tfrazier
ID: 1411370
I have tried your method and IT WORKS. Thank you. The mapping is a little messy but not to bad. This does solve over half our problem as displaying is absolutely necessary and editing would be a great convenience (and our customers will certainly want it). It may be possible to use your method while editing but it would be even more tricky and you'd have to handle the I beam yourself, plus I'm sure other details. Anyway, I have a workaround for now and will implement with your method. But I'm still going to search for a more general solution. Once again, thank you very much for the insight !!!
0
 
LVL 2

Accepted Solution

by:
anichini earned 200 total points
ID: 1411371
you are welcome... answer is above

0
 

Author Comment

by:tfrazier
ID: 1411372
Thanks again.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

14 Experts available now in Live!

Get 1:1 Help Now