不同的显示器它分辨率不相同,
如何在显示器屏幕上绘制一条直线呢?
注意:不是在某个窗体上绘制,而是在整个显示器屏幕上画线,是不是要先获得什么句柄?该如何实现
我是想,打开这个程序 就会在屏幕上显示一个十字坐标......
下面是在 一个窗体上绘制图片的代码(可我要的不是在这个窗口里绘制,要能绘制在整个屏幕上) private void btnShow_Click(object sender, EventArgs e)
{
Graphics g;
Pen p = new Pen(Color.Black);
g = this.CreateGraphics();
int width = ClientRectangle.Width;
int height = ClientRectangle.Height;
g.DrawLine(p, 0, 0, width, height);
p.Dispose();
g.Dispose(); }
如何在显示器屏幕上绘制一条直线呢?
注意:不是在某个窗体上绘制,而是在整个显示器屏幕上画线,是不是要先获得什么句柄?该如何实现
我是想,打开这个程序 就会在屏幕上显示一个十字坐标......
下面是在 一个窗体上绘制图片的代码(可我要的不是在这个窗口里绘制,要能绘制在整个屏幕上) private void btnShow_Click(object sender, EventArgs e)
{
Graphics g;
Pen p = new Pen(Color.Black);
g = this.CreateGraphics();
int width = ClientRectangle.Width;
int height = ClientRectangle.Height;
g.DrawLine(p, 0, 0, width, height);
p.Dispose();
g.Dispose(); }
解决方案 »
- 在c#中, 使用键值对存储数据的是
- byte数组填充字符是什么
- 验证请各位看看 谢谢!
- 如何获取动态链接库的接口参数及其类型?
- 在部署我的应用程序时如何实现安装时在开始菜单或用户桌面上建立指向应用程序的快捷方式
- 关于二进制流的问题?
- 高分求解,两个应用程序之间传值问题
- form 认证, 我的default页面 不在根目录下,每次认证却导航到根本default页面
- 小弟征集c#.net开发web程序的常用代码片断~~~~嘻嘻,收集好了与大家共亨~~~~
- 救命啊,不能调试啊
- C#调用LabView开发工具编译的一个dll文件报错,求指教
- IIS6.0下,CS中操作pfx的方法报错:系统找不到指定的文件
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags);RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85);
我去查了一下,可以发现我不会用啊,小弟是新手,大哥给提示一下 该用在什么地方?是不是 直接添加在
public partial class Form1 : Form
{}
里面? 还是可以直接可以写在按钮事件里?
你看下面这样写对不?
using System.Runtime.InteropServices;namespace Test10._27_Llc
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags); public Form1()
{
InitializeComponent();
} private void btnShow_Click(object sender, EventArgs e)
{
RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85); }
}
}
你看下面这样写对不?
using System.Runtime.InteropServices;namespace Test10._27_Llc
{
public partial class Form1 : Form
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool RedrawWindow(IntPtr hwnd, RECT rcUpdate, IntPtr hrgnUpdate, int flags); public Form1()
{
InitializeComponent();
} private void btnShow_Click(object sender, EventArgs e)
{
RedrawWindow(GetDesktopWindow(), null, IntPtr.Zero, 0x85); }
}
}
错误 2 参数 2: 无法从“<null>”转换为“Win32.RECT” C:\Users\dcx\Documents\Visual Studio 2010\Projects\屏幕绘图\屏幕绘图\Form1.cs 28 46 屏幕绘图