Live Chat Icon For mobile
Live Chat Icon

How can I draw outside my WIndow

Platform: WinForms| Category: Win32

You have to get a handle to the desktop and draw on the desktop. This means that whatever you draw will not be automatically refreshed when another window is dragged over it.

	[DllImport('User32.dll')]
	public extern static System.IntPtr GetDC(System.IntPtr hWnd);

	private void button1_Click(object sender, System.EventArgs e)
	{
		System.IntPtr DesktopHandle = GetDC(System.IntPtr.Zero);
		Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle);
		g.FillRectangle(new SolidBrush(Color.Red),0,0,100,100);
	}

from a microsoft.public.dotnet.framework.windowsforms posting by Lion Shi (MS)

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.