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

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds