Put a Label and a Timer on a Form and try this code:-
vbnet Code:
Public Class Form1 Private g_cnt As Integer Private Function ResizeBitmap(ByVal bmp As Bitmap, ByVal newSize As Size) As Bitmap Return New Bitmap(bmp, newSize) End Function Private Function GetScreenCapture(ByVal rect As Rectangle) As Bitmap Dim bmp As New Bitmap(rect.Width, rect.Height) Dim g As Graphics = Graphics.FromImage(bmp) g.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size) Return bmp End Function Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim cap = GetScreenCapture(New Rectangle(0, 0, 400, 400)) cap = ResizeBitmap(cap, Me.Size) Me.BackgroundImage = cap g_cnt += 1 Label1.Text = g_cnt.ToString End Sub End Class
I set the Timer to 255. That code does a partial screen capture every time the Timer fires and it works fine for me with no errors. Why don't you try it out and see if it works for you as well.




Reply With Quote