
Just remember, love is live, and hate is living death!
Black Sabbath: A National Acrobat
“Transparent” TEdit on TTabSheet
14 Dec 2011 | No Comments | posted by CCRDude | in General Development
From time to time, I encounter the same issue. I’ve got a TPageControl, a TTabSheet on it, and a simply TEdit that replaced a TLabel just for the purpose of the content to be copyable.
BorderStyle is set to bsNone, ReadOnly to True, ad it looks just like a label on modern Windows.
But as soon as you use this on a Windows that uses the classic style (the one that looks a bit like Windows 2000), the tabsheets do no longer have a white background, but a clBtnFace one, and since TEdit is not really tranparent, they look out of place suddenly.
I searched the Delphi-PRAXiS forum for solutions, and found a TTransEdit component there – but that one, I had already discarded years ago, and again didn’t solve the issue for me.
Annoyed by all these struggles, I went another route. I added UXTheme to the uses clause, and simply updated the color based on theming.
procedure TformNTProcess.FormCreate(Sender: TObject);
begin
FProcessImageName := '';
FTerminated := false;
if not UseThemes then begin
editImageName.Color := clBtnFace;
editImageNameNT.Color := clBtnFace;
end;
end;
So far, this works much better and reliable than replacing all TEdit with TTransEdit. Granted, it does not provide transparency for background images, but it solves the TTabSheet theming issue better than a nonperfect transparency solution.

This article was written by: CCRDude