RichEdit Overlay (non-MFC)


The image shows the graphical output of the enclosed test application.

This snippet demonstrates how to make a RichEdit control transparent -- so that the text draws over top of the contents of the parent window (or even a memory DC). Best of all, it should work all the way back to Win95 / NT 3.1 and only relies on the Win32 APIs.

The basic concept is to draw the contents of the control into a memory DC, then use BitBlt() techniques (or TransparentBlt() if available) to generate a mask and overlay the text directly over the target DC.

Obvious enhancements include preallocating the memory DC and mask, then imaging the text only when it changes.

This code is hereby placed in the public domain.

Downloads

Download demo project - 51 Kb
Download source - 3 Kb


Comments

  • Thanks for the tip

    Posted by bruuunooo on 07/27/2005 07:34am

    Hi, I was looking for a way to use richedit controls in mingw C applications. Although it is not the main scope of your article, you provided the example and now it works fine. Oh, and bravo for coding pure C and API calls ! Thanks

    Reply
  • Not work under w2k

    Posted by Legacy on 08/27/2003 12:00am

    Originally posted by: vito

    Demo not working under win2k sp3 - black square only ...
    ADD: Sorry, read about Richedit DLL versions. Question abandoned now.

    Reply
  • Not working in Windows XP

    Posted by Legacy on 09/30/2002 12:00am

    Originally posted by: Akash Kava

    In windows xp your demo shows up complete black rectangle, what a joke.. you havent tested it in NT environment I guess.

    -Akash Kava

    Reply
  • Windows 2000 trouble

    Posted by Legacy on 05/07/2001 12:00am

    Originally posted by: Uwe L�ers

    I could not get the sample app to work under Windows 2000 (tested on three different machines, one with SP1 installed). Seems like the WM_PRINT-Message is not handled correctly. Windows 95/98/NT works fine. Any ideas ?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • A modern mobile IT strategy is no longer an option, it is an absolute business necessity. Today's most productive employees are not tied to a desk, an office, or a location. They are mobile. And your company's IT strategy has to be ready to support them with easy, reliable, 24/7 access to the business information they need, from anywhere in the world, across a broad range of communication devices. Here's how some of the nation's most progressive corporations are meeting the many needs of their mobile workers …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds