How to capture non .net window as a bitmap

J

John Dann

Can anyone point me towards an outline of how to capture the window of
a separate and concurrently running but non .Net program as a bitmap
in VB2005 please? (I'm assuming that there is some way of doing this.)
Ideally I'd like to capture just the client area but if only the total
window area is on offer then I can work with that.

I can see that I need to get the handle of the target window and use
ComInterop, but it's the actual bitmap capture part that I'm
struggling with. I guess I could:

1. Activate the target window;

2. Pass a PrintScreen command via SendKeys (does that still work in
VB2005?)

3. Copy the image into my own app from the clipboard.

But that all seems a bit clunky. Are there any better options?
 
A

Armin Zingler

John said:
Can anyone point me towards an outline of how to capture the window of
a separate and concurrently running but non .Net program as a bitmap
in VB2005 please? (I'm assuming that there is some way of doing this.)
Ideally I'd like to capture just the client area but if only the total
window area is on offer then I can work with that.

I can see that I need to get the handle of the target window and use
ComInterop, but it's the actual bitmap capture part that I'm
struggling with. I guess I could:

1. Activate the target window;

SetForegroundWindow (API function)
2. Pass a PrintScreen command via SendKeys (does that still work in
VB2005?)

3. Copy the image into my own app from the clipboard.
System.Drawing.Graphics.CopyFromScreen

But that all seems a bit clunky. Are there any better options?

Yes and no. (AFAIK)


Armin
 

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