|
-
Aug 18th, 2010, 06:43 AM
#1
[RESOLVED] Capture a screen area underneath a Form
The application I am making, a screen magnifier, requires a partly transparent Form to remain visible but to capture part of the screen underneath the Form. This is easy to do in VB.Net using Graphics.CopyFromScreen, but it has one drawback: CopyFromScreen can't "see" other Windows Forms with opacity less than 1 -- in other words, anything with partial transparency. The only other method I know to capture an area of screen, using BitBlt, captures exactly the pixels that are visible on the screen; but this requires the Form to be hidden during capturing. That causes ugly blinking of the magnifier.
Can anyone here think of another way to capture an area of screen "underneath" a visible form? For example, is there some API-based method to capture all the virtual window rectangles that intersect with the area to be captured, and to use that data to build up an image of what would be visible if the Form is hidden?
BB
-
Aug 22nd, 2010, 04:03 PM
#2
-
Aug 22nd, 2010, 04:05 PM
#3
-
Aug 23rd, 2010, 05:30 PM
#4
Re: Capture a screen area underneath a Form
 Originally Posted by manavo11
To capture layered windows in that post I changed the BitBlt call to vbSrcCopy Or CAPTUREBLT in Sub UpDateImage().
Code:
Private Const CAPTUREBLT As Long = &H40000000
-
Aug 23rd, 2010, 06:56 PM
#5
Re: Capture a screen area underneath a Form
Thanks manovo11 and Edgemeal for your attention to this question. I have been reading further but so far I haven't seen signs of an alternative to either BitBlt with ROP = SRCCOPY OR CAPTUREBLT or GDI+'s CopyFromScreen. I suppose I ought to look at WPF too, but that will have to wait. I now realize I could improve the "blinking" problem in several ways -- use a separate window area to magnify the area round the mouse cursor, or take advantage of a memory copy of the whole screen as in Edgemeal's code. In fact it's not too bad as long as the area of the blink is small and the blink rate isn't too fast.
Unlike CopyFromScreen, BitBlt with CaptureBLT can detect Forms with Opacity<100% as long as the area isn't covered; I'm planning to try that out with per-pixel alpha blended windows too. Unfortunately I've found it cannot see certain Web content displayed in a .Net WebBrowser control, such as the screen text and thumbnails in YouTube (but it does get the Flash video). CopyFromScreen performs better in that respect. I know next to nothing about web browser technicalities (ActiveX?) or about DCs etc. So I'd be glad of any suggestions for overcoming that problem.
Meanwhile it looks like I am stuck with two imperfect techniques. One can't capture transparent, the other can't capture certain web material. I suppose I could offer two modes, one with BitBlt and the other with CopyFromScreen but that is hardly a seamless user exerience. I want a magnifier that will just magnify whatever's on the screen
BB
-
Aug 24th, 2010, 06:39 PM
#6
New Member
Re: Capture a screen area underneath a Form
I use Printwindow. It copies the entire window, even if the window if off screen or beneath another window. I'm not sure about web stuff. Hope that helps.
http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
-
Aug 24th, 2010, 08:52 PM
#7
Re: Capture a screen area underneath a Form
 Originally Posted by McBluffin
Printwindow doesn't work as expected on layered windows or where opacity has been set AFAIK.
-
Sep 1st, 2010, 09:19 AM
#8
Re: Capture a screen area underneath a Form
Thanks for the suggestion McBluffin. I wondered about PrintWindow but I clearly needed to capture the whole stack of windows under the form including transparent ones.
Anyway, it turns out that the failure of BitBlt + SrcCopy Or CaptureBlt wasn't a matter of web content. It only happens with the VS2008 WebBrowser (Version 2.something) which I was using and not to FireFox, IE7 or anthing else I have tried. The WebBrowser in VS2010 (Version 4.something) is also okay and so is WPF.
I suppose I can live without capturing WebBrowser2 displays and their ilk. Still, I wonder how it is that Graphics.CopyFromscreen, which is supposed to be a managed wrapper for BitBlt, does succeed in capturing the blighters?
Now I realise that the problem of having to hide the part of the form over the area captured is largely a question of design. So I can consider this thread resolved.
EDIT: by the way, both BitBlt with CaptureBlt and CopyFromScreen work in their own way with layered windows with per-pixel alpha. CaptureBlt captures everything, CopyFromScreen ignores pixels with alpha < 255.
Thanks all for your help. BB
Last edited by boops boops; Sep 1st, 2010 at 09:26 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|