使用C#实现在屏幕上画图效果的代码实例_C#教程-查字典教程网
使用C#实现在屏幕上画图效果的代码实例
使用C#实现在屏幕上画图效果的代码实例
发布时间:2016-12-28 来源:查字典编辑
摘要:以下这段C#代码实现的功能是在屏幕上画图的效果!具体代码如下:复制代码代码如下://DllImport所在的名字空间usingSystem....

以下这段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));

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新C#教程学习
    热门C#教程学习
    编程开发子分类