[DllImport("User32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] public static extern void ReleaseDC(IntPtr hwnd, IntPtr dc); //Get a Graphics object for the entire screen and draw a rectangle with it: int currentLine = 0, totalNumOfLines=12; Point point = new Point(60, 60); private void FormSettings_Load(object sender, EventArgs e) { desktopPtr = GetDC(IntPtr.Zero); g = Graphics.FromHdc(desktopPtr); } IntPtr desktopPtr; Graphics g; private void FormSettings_FormClosed(object sender, FormClosedEventArgs e) { g.Dispose(); ReleaseDC(IntPtr.Zero, desktopPtr); } private void timerDraw_Tick(object sender, EventArgs e) { g.Dispose(); ReleaseDC(IntPtr.Zero, desktopPtr); desktopPtr = GetDC(IntPtr.Zero); g = Graphics.FromHdc(desktopPtr); currentLine++; if (currentLine == totalNumOfLines) currentLine = 0; g.DrawLine(new Pen(Color.Yellow, 2), point.X, point.Y , point.X + (int)(50 * Math.Cos((currentLine / (double)totalNumOfLines) * Math.PI * 2)) , point.Y + (int)(50 * Math.Sin((currentLine / (double)totalNumOfLines) * Math.PI * 2))); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)