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

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

  • The first phase of API management was about realizing the business value of APIs. This next wave of API management enables the hyper-connected enterprise to drive and scale their businesses as API models become more complex and sophisticated. Today, real world product launches begin with an API program and strategy in mind. This API-first approach to development will only continue to increase, driven by an increasingly interconnected web of devices, organizations, and people. To support this rapid growth, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds