Possible Duplicate:
How to effectively draw on desktop in C#?
I am trying to draw a rectangle on the desktop using the following code, but then the rectangle being drawn is getting erased on refreshing the screen or by opening any other window. am following the below code:
class Program {
[DllImport("User32.dll")]
static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User32.dll")]
static extern void ReleaseDC(IntPtr dc);
static void Main(string[] args) {
IntPtr desktop = GetDC(IntPtr.Zero);
using (Graphics g = Graphics.FromHdc(desktop)) {
g.FillRectangle(Brushes.Red, 0, 0, 100, 100);
}
ReleaseDC(desktop);
}
}
Is there any way to resolve my issue so that the rectangle being drawn would stay persistently?...someone, please let me know the way to resolve it. Thanks in advance.