UpdateLayeredWindow with normal canvas/textout

余生长醉 提交于 2019-12-05 14:04:18

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!