Solved

Transparent RICHEDIT

Posted on 1998-02-18
10
1,074 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

775 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