在写一此帮助说明类的文档时,截取的图片如果还有鼠标的指针形状,看起来就更直观更友好一些。接下来就讲一下如何在截图中包含鼠标指针形状。
上一篇:C#软件开发实例.私人订制自己的屏幕截图工具(九)使用自定义光标,QQ截图时的光标
[StructLayout(LayoutKind.Sequential)] struct CURSORINFO { public int cbSize; public int flags; public IntPtr hCursor; public Point ptScreenPos; }
[DllImport("user32.dll")] static extern bool GetCursorInfo(out CURSORINFO pci);
private const int CURSOR_SHOWING = 0x00000001;
/// <summary> /// 将鼠标指针形状绘制到屏幕截图上 /// </summary> /// <param name="g"></param> private void DrawCursorImageToScreenImage(ref Graphics g) { if (!this.IsCutCursor) { return; } CURSORINFO vCurosrInfo; vCurosrInfo.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); GetCursorInfo(out vCurosrInfo); if ((vCurosrInfo.flags & CURSOR_SHOWING) != CURSOR_SHOWING) return; Cursor vCursor = new Cursor(vCurosrInfo.hCursor); Rectangle vRectangle = new Rectangle(new Point(vCurosrInfo.ptScreenPos.X - vCursor.HotSpot.X, vCurosrInfo.ptScreenPos.Y - vCursor.HotSpot.Y), vCursor.Size); vCursor.Draw(g, vRectangle); }
OK,再去截图看看吧!
C#软件开发实例.私人订制自己的屏幕截图工具(十)在截图中包含鼠标指针形状,布布扣,bubuko.com
C#软件开发实例.私人订制自己的屏幕截图工具(十)在截图中包含鼠标指针形状
原文地址:http://blog.csdn.net/testcs_dn/article/details/33000583