Within your own window you can draw using the Graphics object passed in the
OnPaint or Paint event arguments.
Dou you mean directly on the desktop? Yes you can by obtaining the desktop
handle and wrapping it in a GDI+ Graphics object using Graphics.FromHd c.
I generally use interop for this and import the GetDc and ReleaseDc methods.
You must remember to correctly release DC's when you do this.
It's not neat or pretty though...
[DllImport("User 32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("User 32.dll")]
public static extern void ReleaseDC(IntPt r dc);
protected override void OnPaint(PaintEv entArgs e)
{
SolidBrush b=new SolidBrush(Colo r.Red);
IntPtr desktopDC=GetDC (IntPtr.Zero);
Graphics g = Graphics.FromHd c(desktopDC);
g.FillEllipse(b ,0,0,1024,768);
g.Dispose();
ReleaseDC(deskt opDC);
}
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"redneon" <re*****@discus sions.microsoft .com> wrote in message
news:05******** *************** ***********@mic rosoft.com...
Is it possible to draw directly to the screen using the .net libraries? I
thought that it might be possible with GDI+ but I can't find out how to do
it
anywhere. A part of me suspects I may have to look into using the Windows
API.
Any ideas,
Darrell