Hi,
I use the code below to call another class "ScreenCapture.vb".
But I got a lot of errors.
'Me' is not valid within a Module
Thanks for your help.
The other class is briefly listed asCode:Module ModuleSC Sub Main() Dim SC As New ScreenShot.ScreenCapture 'grabs image of object handle (in this case, the form) Dim MyWindow As Image = SC.CaptureWindow(Me.Handle) 'grabs image of entire desktop Dim MyDesktop As Image = SC.CaptureScreen 'captures entire desktop straight to file SC.CaptureScreenToFile("c:\desktop2.jpg", Imaging.ImageFormat.Jpeg) 'captures image of object handle (in this case, the form) straight to file SC.CaptureWindowToFile(Me.Handle, "c:\window2.jpg", Imaging.ImageFormat.Jpeg) 'returns bitmap of region of desktop by passing in a rectangle Dim MyBitMap As Bitmap = SC.CaptureDeskTopRectangle(New Rectangle(Me.Location.X, Me.Location.Y, _ Me.Width, Me.Height), Me.Width, Me.Height) MyBitMap.Save("c:\desktopregion.jpg", Imaging.ImageFormat.Jpeg) 'above example gets rectangle of form that it is called in, you can get 'desktop by calling me.hide before the actual function call in order to 'get the desktop that is in the bounds of the form (handy when using a 'transparent Form or control in order to make a "viewfinder" for the capture...) 'You can pass in any rectangle you want, this was so you can see how 'it works... End Sub End Module
Code:Imports System Imports System.Runtime.InteropServices Imports System.Drawing Imports System.Drawing.Imaging Namespace ScreenShot Public Class ScreenCapture '/ Creates an Image object containing a screen shot of the entire desktop Public Function CaptureScreen() As Image Return CaptureWindow(User32.GetDesktopWindow()) End Function 'CaptureScreen '/ Creates an Image object containing a screen shot of a specific window Public Function CaptureWindow(ByVal handle As IntPtr) As Image Dim SRCCOPY As Integer = &HCC0020 ' get te hDC of the target window Dim hdcSrc As IntPtr = User32.GetWindowDC(handle) '......many lines then




Reply With Quote