A code instance that USES C to draw on the screen
- 2020-05-12 03:04:07
- OfStack
The following C# code implements the ability to draw pictures on the screen! The specific code is as follows:
//DllImport The name space
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));
}