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

  • With JRebel, developers get to see their code changes immediately, fine-tune their code with incremental changes, debug, explore and deploy their code with ease (both locally and remotely), and ultimately spend more time coding instead of waiting for the dreaded application redeploy to finish. Every time a developer tests a code change it takes minutes to build and deploy the application. JRebel keeps the app server running at all times, so testing is instantaneous and interactive.

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds