Yesterday I've stumbled upon an interesting demo of a transparent RichEdit control made for VisualC++ at The Code Project (called «See through Rich Edit control»). I'm currently writing an app in Delph 7 which uses TRichEdit as a log/console window and looking at that demo with cute Mario face I thought how cool would it make plain console window look like that too.

I went digging and discovered that to create a transparent RichEdit you simply and merely need to create its window with WS_EX_TRANSPARENT style – and also supply an WM_ERASEBKGND handler to make sure no junk is left from previous redraws.
Adding a custom style seemed a trivial task in Delphi – simply override TWinControl'sCreateParams method and add your style to ExStyle. However, this didn't work out for some reason (the control was behaving like it known nothing of WS_EX_TRANSPARENT)) but resorting to this method:

pascalprocedure TTransparentRichEdit.CreateWnd;
begin
  inherited;
  SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT);
end;

…fixed that.

Hurray, now we only need to hook WM_ERASEBKGND – no surprises here so you can proceed to downloading the component without furner ado from my side :)

Download TTransparentRichEdit control (it has no external dependencies).

If you haven't installed any custom component yet simply go to Component → Install component menu. Note that this class was written and tested on Delphi of 7th version only.

http://proger.i-forge.net/Мои проги/Delphi/Transparent RichEdit/index.png

Usage notes

What you see here is actually a TTransparentRichEdit control with Nagato’s portrait PNG loaded (the Background property), below which lies a standard TImage with a JPEG picture shining through the RichEdit’s background.

However, use such tricks with overlaying controls on your risk because it might result in glitches – for example, TImage seems to be painted after the RichEdit receives WM_ERASEBKGND and thus it fully overlays the latter when window is resized.
It works fine when there’s nothing below RichEdit, though.