软件编程
位置:首页>> 软件编程>> C#编程>> 使用C#实现在屏幕上画图效果的代码实例

使用C#实现在屏幕上画图效果的代码实例

  发布时间:2022-09-11 05:12:32 

标签:C#,实现,屏幕上画图

以下这段C#代码实现的功能是在屏幕上画图的效果!具体代码如下:


//DllImport所在的名字空间
 using System.Runtime.InteropServices;
[DllImport("User32.dll")]
public extern static System.IntPtr GetDC(System.IntPtr hWnd); 
private void button19_Click(object sender, EventArgs e)
{
    System.IntPtr    DesktopHandle   =    GetDC(System.IntPtr.Zero);
    Graphics g = Graphics.FromHdc(DesktopHandle);
    g.DrawRectangle(new Pen(Color.Red),new Rectangle(10,10,100,100));
}


0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com