我们可以在一个表格之外绘制图像和绘制文本……我的意思是字面上在外…
我知道要问的愚蠢问题,但我们能……
解决方法@H_301_6@
您可以通过创建表单并将其TransparentColor属性设置为其背景颜色来“欺骗”,然后在其上绘制.但是,这会禁止您绘制透明色,因为它不会显示.
或者您实际上可以直接绘制到桌面.
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
public static extern void ReleaseDC(IntPtr dc);
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Graphics g = Graphics.FromHdc(desktopPtr);
// Do graphics manipulation here with "g" object
// Very important - free desktop graphics.
g.Dispose();
ReleaseDC(desktopPtr);
或者您实际上可以直接绘制到桌面.
[DllImport("User32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] public static extern void ReleaseDC(IntPtr dc);
IntPtr desktopPtr = GetDC(IntPtr.Zero); Graphics g = Graphics.FromHdc(desktopPtr); // Do graphics manipulation here with "g" object // Very important - free desktop graphics. g.Dispose(); ReleaseDC(desktopPtr);