How to capture active window as screenshot?

D

Dean Slindee

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
 
D

Dean Slindee

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
 
H

Herfried K. Wagner [MVP]

* "Dean Slindee said:
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()
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top