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

Transparent RICHEDIT

Posted on 1998-02-18
10
1,077 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

0
 

Author Comment

by:tfrazier
ID: 1411372
Thanks again.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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
Automating Allen Browne's Audit Trail for a large Database 7 53
SignTool Error with Windows 10 5 178
Best book to learn C++ 4 84
Is IHttpActionResult a promise pattern? 2 68
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…

860 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