How to capture non .net window as a bitmap

  • Thread starter Thread starter John Dann
  • Start date Start date
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?
 
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
 
Back
Top