By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

How to capture active window as screenshot?

P: n/a
I would like to capture a picture of the active window on the screen to use
in an error routine.
Like the following, which captures the entire desktop:
Dim objRectangle As Rectangle = Screen.PrimaryScreen.Bounds

Dim objBitmap As New Bitmap(objRectangle.Right, objRectangle.Bottom)

How can I isolate down to just the active window?

Thanks,

Dean Slindee
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* "Dean Slindee" <sl*****@charter.net> scripsit:
I would like to capture a picture of the active window on the screen to use
in an error routine.


<URL:http://dotnet.mvps.org/dotnet/samples/windowsandforms/downloads/Screenshot.zip>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2

P: n/a
Care to double check my testing of this project? It appears that the code
to capture the active window is there, but that there is no way provided to
branch into that code. It always takes a desktop screenshot.

What code would it snap an active window screenshot?

Thanks,
Dean Slindee
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eA**************@TK2MSFTNGP09.phx.gbl...
* "Dean Slindee" <sl*****@charter.net> scripsit:
I would like to capture a picture of the active window on the screen to use in an error routine.

<URL:http://dotnet.mvps.org/dotnet/sample...nloads/Screens
hot.zip>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3

P: n/a
* "Dean Slindee" <sl*****@charter.net> scripsit:
Care to double check my testing of this project? It appears that the code
to capture the active window is there, but that there is no way provided to
branch into that code. It always takes a desktop screenshot.

What code would it snap an active window screenshot?


\\\
Private Declare Function GetForegroundWindow Lib "user32.dll" () As IntPtr
..
..
..
foo.Window = GetForegroundWindow()
Dim b As Bitmap = foo.Capture()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
<URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.