468,301 Members | 1,436 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

Screen Capture Frustration

I have one here that I cannot find anything on in my searching.

I am implementing a screen capture functionality into my Visual Basic
..NET application.

The code I am using calls the bitblt function in gdi32.dll to achieve
its magic as follows:

Public Function CreateScreenshot() As Bitmap

Dim Rect As Rectangle = Screen.PrimaryScreen.Bounds
Dim gDest As Graphics
Dim hdcDest, hdcSrc As IntPtr

CreateScreenshot = New Bitmap(Rect.Right, Rect.Bottom)
gDest = gDest.FromImage(CreateScreenshot)

hdcSrc = GetDC(IntPtr.Zero)
hdcDest = gDest.GetHdc
BitBlt(hdcDest, 0, 0, _
Rect.Right, Rect.Bottom, hdcSrc, 0, 0, SRCCOPY)
gDest.ReleaseHdc(hdcDest)
ReleaseDC(IntPtr.Zero, hdcSrc)

End Function
This code works marvelously HOWEVER.....

This screen capture needs to capture my form (which is opaque) ontop
another form.

I have found that when the opacity for the topmost form is set less
than 100 % it does not show up in my capture.

The interesting thing is that a Ctrl-Alt-Print Screen yields the
opaque form in the resulting capture perfectly.

I have some ideas as to why this might be occuring ( gdi functions not
supporting nifty rendering features like opacity being at the top)

Nothing I have come up with at this point (and my skill levels) lead
me to any obvious solutions

I would rather not use Sendkeys and the clipboard as I feel that this
is shoddy at best.

Anybody have any ideas?
Thanks In Advance

Eddie
Nov 21 '05 #1
2 1903
"Eddie Dunn" <ge*****@uncw.edu> schrieb:
I am implementing a screen capture functionality into my Visual Basic
.NET application.

The code I am using calls the bitblt function in gdi32.dll to achieve
its magic as follows:
[...]
This code works marvelously HOWEVER.....

This screen capture needs to capture my form (which is opaque) ontop
another form.

I have found that when the opacity for the topmost form is set less
than 100 % it does not show up in my capture.

The interesting thing is that a Ctrl-Alt-Print Screen yields the
opaque form in the resulting capture perfectly.

I have some ideas as to why this might be occuring ( gdi functions not
supporting nifty rendering features like opacity being at the top)

Nothing I have come up with at this point (and my skill levels) lead
me to any obvious solutions


Try this sample:

<URL:http://dotnet.mvps.org/dotnet/sample...nloads/Screens
hot.zip>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:<uU*************@TK2MSFTNGP10.phx.gbl>...
"Eddie Dunn" <ge*****@uncw.edu> schrieb:
I am implementing a screen capture functionality into my Visual Basic
.NET application.

The code I am using calls the bitblt function in gdi32.dll to achieve
its magic as follows:
[...]
This code works marvelously HOWEVER.....

This screen capture needs to capture my form (which is opaque) ontop
another form.

I have found that when the opacity for the topmost form is set less
than 100 % it does not show up in my capture.

The interesting thing is that a Ctrl-Alt-Print Screen yields the
opaque form in the resulting capture perfectly.

I have some ideas as to why this might be occuring ( gdi functions not
supporting nifty rendering features like opacity being at the top)

Nothing I have come up with at this point (and my skill levels) lead
me to any obvious solutions


Try this sample:

<URL:http://dotnet.mvps.org/dotnet/sample...nloads/Screens
hot.zip>


Thanks a million! Works Perfectly
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Me Mine | last post: by
1 post views Thread by xc | last post: by
3 posts views Thread by Per | last post: by
1 post views Thread by Jody Gelowitz | last post: by
2 posts views Thread by py | last post: by
2 posts views Thread by dumbledad | last post: by
4 posts views Thread by Paolo Pantaleo | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.