C#如何在显示器上画图(就是不画到C#的控件中)
解决方案 »
- 子类和父类的Clone
- 我想问个问题,做B/S结构用到技术多,还是做C/S结构用到的技术多呢
- 一个关于List.Sort()方法的疑问——用List.Sort()方法排序结果不正确!!
- 求一个格式字符串
- 如何从PDF文件里提取文本出来?
- system.ComponentModel.Win32Exception”类型的异常出现在 system.dll 中。 设备未就绪
- 菜鸟提问,一个not all code paths return a value错误
- 类型转换。在线等。解决就给分。急
- 两个form,相互调用的问题
- 请各位高手推荐基本经典的c#教程,最好比较全面的!
- GPS/GIS软件开发
- 用c#写个程序将整张网页截图并保存,请高手给思路和代码!
Dim p As System.IntPtr = GetDC(0) '取得屏幕
Dim g As Graphics = Graphics.FromHdc(p)
g.DrawRectangle(New Pen(Color.Black), 100, 100, 100, 100)
private static extern int GetDC(int hwnd); private void button1_Click(object sender, EventArgs e)
{
System.IntPtr p = (IntPtr)GetDC(0);// '取得屏幕
Graphics g= Graphics.FromHdc(p);
g.DrawRectangle(new Pen(Color.Black),new Rectangle (100,100,100,100)); }
[DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr IntGetDCEx(HandleRef hWnd, HandleRef hrgnClip, int flags);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern bool RedrawWindow(HandleRef hwnd, ref RECT rcUpdate, HandleRef hrgnUpdate, int flags);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", EntryPoint = "GetDCEx", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetDCEx(IntPtr hWnd, IntPtr hrgnClip, int flags);private void button1_Click(object sender, EventArgs e)
{
IntPtr desk = GetDesktopWindow();
IntPtr deskDC = GetDCEx(desk, IntPtr.Zero, 0x403);
Graphics g = Graphics.FromHdc(deskDC);
g.FillEllipse(SystemBrushes.ControlText, 0, 0, 100, 100);
}