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: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Hundreds of millions of users have adopted public cloud storage solutions to satisfy their Private Online File Sharing and Collaboration (OFS) needs. With new headlines on cloud privacy issues appearing almost daily, the need to explore private alternatives has never been stronger. Join ESG Senior Analyst Terri McClure and Connected Data in this on-demand webinar to take a look at the business drivers behind OFS adoption, how organizations can benefit from on-premise deployments, and emerging private OFS …

Most Popular Programming Stories

More for Developers

RSS Feeds