使用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));
}
相关推荐
-
C#给图片加水印的简单实现方法
本文实例讲述了C#给图片加水印的简单实现方法.分享给大家供大家参考.具体分析如下: 这里实现本网站图片保护功能类: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Drawing;//image的命名空间 namespace 实现本网站图片保护功能 { public class yanzhengma:IHttpHandler { public boo
-
C#画图之饼图折线图的实现方法
本文实例讲述了C#画图之饼图折线图的实现方法,是C#程序设计中非常实用的技巧.分享给大家供大家参考.具体方法分析如下: 显示图像的控件定义如下: public PlaceHolder PlaceHolder1; 各个图像的类别名称如下: PictureType 图形种类 5 chChartTypeBarClustered 簇状条形图 0 NULL PictureType 图形种类 7 chChartTypeBarClustered3D
-
C#图片上传效果实例分析
本文实例讲述了C#图片上传效果实现方法.分享给大家供大家参考.具体如下: <%@ Page Title="" Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> <asp:Conte
-
C#非矩形窗体实现方法
本文实例讲述了C#非矩形窗体实现方法.分享给大家供大家参考.具体实现方法如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace Win
-
C#通过反射获取当前工程中所有窗体并打开的方法
本文实例讲述了C#通过反射获取当前工程中所有窗体并打开的方法.分享给大家供大家参考.具体实现方法如下: using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace TestAppHelperMSDNSample { static class Program { /// <summary> /// The main entry point for
-
C#远程发送和接收数据流生成图片的方法
本文实例讲述了C#远程发送和接收数据流生成图片的方法.分享给大家供大家参考.具体如下: 将图片转成数据流方式发送到远程服务,在通过服务器后台程序来接收数据流,再保存成图片存放在需要的地方. 这种方式就类似上传图片功能一样,希望能给一些大家另一种上传图片功能的方法. 发送数据流方法 /// <summary> /// PostBinaryData /// </summary> /// <param name="url">要发送的 url 网址</
-
C#将图片和字节流互相转换并显示到页面上
图片转换成字节流先要转换的IMage对象,转换之后返回字节流.字节流转换成图片,要转换的字节流,转换得到的Image对象,根据图片路径返回图片的字节流,感兴趣的朋友看下下面的代码. C#将图片和字节流相互转换代码: usingSystem; usingSystem.Collections.Generic; usingSystem.Linq; usingSystem.Text; usingSystem.Drawing; usingSystem.IO; namespaceMicrosoft.Form
-
C#透明窗体实现方法
本文实例讲述了C#透明窗体实现方法.分享给大家供大家参考.具体实现方法如下: namespace WindowsApplication1 { public partial class Form2 : Form { public Form2() { InitializeComponent(); this.Opacity = 1; this.Text = "opacity=1"; this.TopMost = true; } private void Form2_Activated(obj
-
C#实现在服务器端裁剪图片的方法
本文实例讲述了C#实现在服务器端裁剪图片的方法.分享给大家供大家参考.具体实现方法如下: //图片路径 String oldPath = Server.MapPath("~/62223231.jpg"); //新图片路径 String newPath = System.IO.Path.GetExtension(oldPath); //设置截取的坐标和大小 int x = 0, y = 20, width = 200, height = 2400; //计算新的文件名,在旧文件名后加_n
-
C#实现由四周向中心缩小的窗体退出特效
本文实例讲述了C#实现由四周向中心缩小的窗体退出特效.分享给大家供大家参考.具体实现方法如下: public const Int32 AW_CENTER = 0x00000010; public const Int32 AW_HIDE = 0x00010000; [DllImport("user32.dll",CharSet=CharSet.Auto)] public static extern bool AnimateWindow(IntPtr hwnd, int dwTime, i
-
C#显示文件夹下所有图片文件的方法
本文实例讲述了C#显示文件夹下所有图片文件的方法.分享给大家供大家参考.具体实现方法如下: <%@ Page Language="C#" EnableViewState="false" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
-
C#实现打开画图的同时载入图片、最大化显示画图窗体的方法
本文实例讲述了C#实现打开画图的同时载入图片.最大化显示画图窗体的方法.分享给大家供大家参考.具体实现方法如下: /// <summary> /// 打开画图的同时载入图片 /// 最大化显示画图窗体 /// </summary> public static void OpenAppShowImage() { System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); i
随机推荐
- .Net消息队列的使用方法
- iOS App开发中修改UILabel默认字体的方法
- 关于数据库连接池Druid使用说明
- asp.net生成验证码代码(纯中文)
- JS实现IE状态栏文字缩放效果代码
- ASP.NET中各个后缀名的含义介绍
- 深入解读php中关于抽象(abstract)类和抽象方法的问题分析
- 《JavaScript高级编程》学习笔记之object和array引用类型
- 跟老齐学Python之类的细节
- java+jsp+struts2实现发送邮件功能
- PowerShell函数简明教程
- linux shell查看当前外网IP
- DevExpress之ChartControl实现时间轴实例
- spring整合JMS实现同步收发消息(基于ActiveMQ的实现)
- React复制到剪贴板的示例代码
- php图形jpgraph操作实例分析
- 解决Android中自定义DialogFragment解决宽度和高度问题
- Ajax 动态载入html页面后不能执行其中的js快速解决方法
- iOS坐标系的深入探究
- C++简单五子棋的AI设计实现