UpdateLayeredWindow with plain canvas / textout

Is there a way to draw on a form with a canvas and then use updatelayeredwindow so that the form is not visible, but the text is like a transparent form showing only text? if not, is there a way to make some kind of translucent form with only canvas (opengl / directx)? I would like to draw with commands at the top of all windows.

+4
source share
1 answer

You can set the TransparentColor property of the form to True, and then set the form color to the same TransparentColorValue , and the entire client area of ​​the form will be transparent. If the Delphi version you are using does not have the TransparentColor [Value] properties, you can achieve the same result 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 transparency of the client area forms. You can draw on canvas as usual:

 procedure TForm1.FormPaint(Sender: TObject); begin Canvas.Font.Color := clWhite; Canvas.TextOut(0, 0, 'Text'); end; 

Of course, you can also put a shortcut in the form with a font color other than transparent.

+7
source

Source: https://habr.com/ru/post/913485/


All Articles