Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2007

Tip: Looking for answers? Try searching our database.

How to get 'Graphics' of the whole screen?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Polaris - 01 Dec 2007 17:18 GMT
Hi Experts:

I'd like to be able to draw image outside my application.

I know I can get a drawing surface for a form by using:
Graphics g = Form.CreateGraphics

Just wonder, if there is similar way to get an instance of Graphics of the
whole screen?

Thanks In Advance!
Polaris
Nicholas Paldino [.NET/C# MVP] - 02 Dec 2007 00:01 GMT
Polaris,

   You can get the windows desktop handle through the P/Invoke layer,
calling the GetDesktopWindow function.

   Once you have that, you can pass the handle to the static FromHwnd
method on the Graphics class to get the graphics instance for that window.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi Experts:
>
[quoted text clipped - 8 lines]
> Thanks In Advance!
> Polaris
Serge Baltic - 02 Dec 2007 00:15 GMT
Hello,

> I'd like to be able to draw image outside my application.

You should create a transparent form for that and paint on it. Even though
you can get a DC to paint “onscreen” (provided that your OS is not Vista),
the image would not be consistent as other apps start moving around or repainting
themselves.

The simplest way is to create a Window (from .NET 3.0) with AllowsTransparency=True,
without any border, and with transparent background — effectively, there
will be just the picture floating onscreen. Prior to 3.0, seems like there's
no easy way. That requires a few PInvoke calls — basically, you should use
PInvoke for CreateCompatibleDC, then CreateBitmap in it, then you can create
a Graphics over that DC, paint whatever needed, and blit that onscreen with
UpdateLayeredWindow.

(H) Serge

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.