当前位置: 首页 > 新闻动态 > 软件编程

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

作者:用户投稿 浏览: 发布日期:2026-01-16
[导读]:本篇文章是对使用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));
}

免责声明:转载请注明出处:http://m.hclxt.cn/news/142315.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!