Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Transparent RICHEDIT

Posted on 1998-02-18
10
Medium Priority
?
1,087 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
[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
  • 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

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
 

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 800 total points
ID: 1411371
you are welcome... answer is above

0
 

Author Comment

by:tfrazier
ID: 1411372
Thanks again.
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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