|
Hi every1, does anyone know if it is possible to capture an image of a form that is behind another form or window?
If this is possible I later want to turn it into video capture of the selected window.
TIA,
Brian
|
|
|
|
|
You want to capture video of a window, which is not visible ?
No - a window that is not visible is not being painted, so there's nothing to capture.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for fast reply.
Then is there some way to paint this to a 'magical' spot that cant be seen and take the image capture from their?
thanks.
|
|
|
|
|
I dunno what would happen if you moved the window outside the bounds of the screen, but it would be a failure on the part of windows if it was painted there. I very much doubt it's easily achieved. If you could pass a DC to the paint event of the control, perhaps it would draw on it, but that would only be the client area, and it's just an idea, I dunno if it would work.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi again, fast response good. This solution seems to work:
<br />
Private Declare Function PrintWindow Lib "user32.dll" (ByVal _<br />
hwnd As IntPtr, ByVal hdcBlt As IntPtr, ByVal nFlags As _<br />
UInt32) As Boolean<br />
Dim screenGrab As Bitmap<br />
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click<br />
Me.SendToBack()<br />
screenGrab = New Bitmap(Me.Width, Me.Height)<br />
Dim g As Graphics = Graphics.FromImage(screenGrab)<br />
Dim hdc As IntPtr = g.GetHdc<br />
Me.PrintWindow(Me.Handle, hdc, Nothing)<br />
g.ReleaseHdc(hdc)<br />
g.Flush()<br />
g.Dispose()<br />
screenGrab.Save("C:\please.bmp", System.Drawing.Imaging.ImageFormat.Bmp)<br />
End Sub<br />
havent tested if thouroughly, but seems ok, howd anyone else run this?
|
|
|
|
|
OK - looks like the Windows API exposes this ability ( to force a paint event ). Cool.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Here is another method.
If you're using .NET 2.0, then you can call the new Form.DrawToBitmap() function.
|
|
|
|
|
thanks for another response, unfortunately cant test this out on .net 1.0.
How would I convert the previous code to remove the Title bar from that captures?
|
|
|
|
|
What you want is just the "client" area inside of the window. I don't know what managed calls you can make to access the handle of the client window.
I've found this on the Internet. Perhaps this will do the trick?
http://www.vbdotnetheaven.com/Code/Jul2003/2128.asp[^]
|
|
|
|
|
thanks, using screenGrab = New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height) i do get the smaller area, but it cuts the bottom and right side area off rather then all edges.
|
|
|
|
|
I've just tried the code sample from the link I gave you. It works. It's only capturing the client area. Are you not using that code?
If you're calling your form's CreateGraphics() method like in the code sample, then it should only capture the client area and not the whole form.
|
|
|
|
|
I thought I tried it, if the window is hidden, didnt that just capture whatever else was ontop for the same region?
|
|
|
|
|
You're right. The code I gave you isn't going to work in this case.
Perhaps the thing to do is once you've got the captured image of the whole window, you could then copy only the inside portion to another bitmap. You already know how to get the client area's width and height. You can get its top/left position using the following code.
Dim clientOffsetPoint As System.Drawing.Point
clientOffsetPoint = Me.PointToClient(New System.Drawing.Point(Me.Left, Me.Top))
clientOffsetPoint.X *= -1
clientOffsetPoint.Y *= -1
|
|
|
|
|
|
Can anyone tell me how to Send/Read/Manage Email with VB 6.0? without any other dll or ocx, only with api function!!
|
|
|
|
|
No, but Google can
One search, first page.
http://www.freevbcode.com/ShowCode.Asp?ID=109[^]
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
Hi guys,
I try to find some informations for creating bitmap regions for forms in vb .net, but with no results! Only in C#: www.codeproject.com/csharp/bmprgnform.asp
So, I need little help from everyone who knows this in vb .net!
Thanx in advance..
|
|
|
|
|
It's the same in VB.NET, they both use the .NET framework, you just need to convert the code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanx for reply Christian...but I am beginner...so, I need help to translate. Help me if you can..or anyone else..
|
|
|
|
|
There are automatic tools to do this, but it really is a trivial task, I convert VB.NEt to C# from time to time, and I don't know VB.NET at all. I'd suggest it's probably an excellent exercise for you. In C#, we use { } instead of endif to define a scope, and we end lines in a ;.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|
Does anyone know how to deploy an application/project in VB.Net?
thanks.
|
|
|
|
|
|
Thanks bro!
|
|
|
|
|