Reputation: 383
Is there a way to draw on form with canvas and then use the updatelayeredwindow so not the form will be visible but the text, like a transculent form showing only text? if not, then is there a way to make some sort of transculent form with only the canvas (opengl/directx) maybe? i would like to draw with commands on the top of all windows.
Upvotes: 4
Views: 1710
Reputation: 54822
You can set the TransparentColor
property of the form to 'True', then set the form color to the same color of TransparentColorValue
, and all of the form's client area will be transparent. If the Delphi version you use does not have the 'TransparentColor[Value]' properties you can achieve the same with API calls:
Color := clBlack;
SetWindowLong(Handle, GWL_EXSTYLE,
GetWindowLong(Handle, GWL_EXSTYLE) or WS_EX_LAYERED );
SetLayeredWindowAttributes(Handle, 0, 255, LWA_COLORKEY);
will make the forms client area transparent. You can paint on the canvas as you normally would:
procedure TForm1.FormPaint(Sender: TObject);
begin
Canvas.Font.Color := clWhite;
Canvas.TextOut(0, 0, 'Text');
end;
Of course you can also put a label on the form having a font color anything different then the transparent color.
Upvotes: 7