This fragment is about to be reported (you'll remain on this page):
You can enter a comment to clarify the mistake if you would like to:
Is IS possible to create a TRichEdit control with transparent background in Delphi.
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;
Download TTransparentRichEdit control (it has no external dependencies).
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.