具有普通画布/文本输出的UpdateLayeredWindow [英] UpdateLayeredWindow with normal canvas/textout
问题描述
是否有一种方法可以使用画布在表单上绘制,然后使用updatelayeredwindow,以便该表单将不可见,而是文本,例如仅显示文本的无形表单?如果没有,那么有没有办法仅使用画布(opengl/directx)来制作某种无形的形式?我想在所有窗口的顶部绘制命令.
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.
推荐答案
您可以将表单的TransparentColor
属性设置为'True',然后将表单颜色设置为与TransparentColorValue
相同的颜色,表单的客户区将是透明的.如果您使用的Delphi版本没有'TransparentColor [Value]'属性,则可以通过API调用实现相同的效果:
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.
这篇关于具有普通画布/文本输出的UpdateLayeredWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!