|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Screen CaptureHello All
VB.NET 2003 Code Only (not C#) How do I capture a window by knowing its class name & save it as a jpg on a button click? Of course the window won't be in focus Any help would be appreciated without Google links please TIA Here is something that that might help get you started ... the CapturePanel
method is probably what your looking for. Imports System.Runtime.InteropServices #Region " Printing Support " <DllImport("gdi32.DLL", EntryPoint:="BitBlt", SetLastError:=True, CharSet:=CharSet.Unicode, _ ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _ Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As System.Int32) As Boolean ' Leave function empty - DLLImport attribute forwards calls to MoveFile to ' MoveFileW in KERNEL32.DLL. End Function 'Returns the panel as a bitmap Private Function CapturePanel() As Bitmap Dim g1 As Graphics = Me.CreateGraphics() Dim MyImage As Bitmap = New Bitmap(Me.ClientRectangle.Width, (Me.ClientRectangle.Height), g1) Dim g2 As Graphics = Graphics.FromImage(MyImage) Dim dc1 As IntPtr = g1.GetHdc() Dim dc2 As IntPtr = g2.GetHdc() BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), dc1, 0, 0, 13369376) g1.ReleaseHdc(dc1) g2.ReleaseHdc(dc2) 'saves image to c drive for testing - comment out for production 'MyImage.Save("c:\abc.bmp") Return MyImage End Function #End Region Show quoteHide quote "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message news:uVl8jtFIHHA.4216@TK2MSFTNGP06.phx.gbl... > Hello All > > VB.NET 2003 Code Only (not C#) > > How do I capture a window by knowing its class name & save it as a jpg on > a > button click? Of course the window won't be in focus > > Any help would be appreciated without Google links please > > TIA > > Thank you for your reply, but how do I get the known class & pass it on to
the CapturePanel Function? Plus I need to capture the window at 100% ratio. How? Show quoteHide quote "Matt Fielder" <mfielderREMOVECAPS@nospam.nospam> wrote in message news:OBrTsVHIHHA.3780@TK2MSFTNGP02.phx.gbl... > Here is something that that might help get you started ... the CapturePanel > method is probably what your looking for. > Imports System.Runtime.InteropServices > > #Region " Printing Support " > > <DllImport("gdi32.DLL", EntryPoint:="BitBlt", SetLastError:=True, > CharSet:=CharSet.Unicode, _ > > ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _ > > Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As > Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As > Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As > Integer, ByVal dwRop As System.Int32) As Boolean > > ' Leave function empty - DLLImport attribute forwards calls to MoveFile to > > ' MoveFileW in KERNEL32.DLL. > > End Function > > > > 'Returns the panel as a bitmap > > Private Function CapturePanel() As Bitmap > > Dim g1 As Graphics = Me.CreateGraphics() > > Dim MyImage As Bitmap = New Bitmap(Me.ClientRectangle.Width, > (Me.ClientRectangle.Height), g1) > > Dim g2 As Graphics = Graphics.FromImage(MyImage) > > Dim dc1 As IntPtr = g1.GetHdc() > > Dim dc2 As IntPtr = g2.GetHdc() > > BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), > dc1, 0, 0, 13369376) > > g1.ReleaseHdc(dc1) > > g2.ReleaseHdc(dc2) > > 'saves image to c drive for testing - comment out for production > > 'MyImage.Save("c:\abc.bmp") > > Return MyImage > > End Function > > #End Region > > "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message > news:uVl8jtFIHHA.4216@TK2MSFTNGP06.phx.gbl... > > Hello All > > > > VB.NET 2003 Code Only (not C#) > > > > How do I capture a window by knowing its class name & save it as a jpg on > > a > > button click? Of course the window won't be in focus > > > > Any help would be appreciated without Google links please > > > > TIA > > > > > > I have the code now I think. Will adapt it & use, but it does capture the
window I pass the handle to so far, but 2 windows have the same class & its this hurdle I need to overcome now Show quoteHide quote "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message news:uS%23BjdHIHHA.1280@TK2MSFTNGP04.phx.gbl... > Thank you for your reply, but how do I get the known class & pass it on to > the CapturePanel Function? > > Plus I need to capture the window at 100% ratio. How? > > > "Matt Fielder" <mfielderREMOVECAPS@nospam.nospam> wrote in message > news:OBrTsVHIHHA.3780@TK2MSFTNGP02.phx.gbl... > > Here is something that that might help get you started ... the > CapturePanel > > method is probably what your looking for. > > Imports System.Runtime.InteropServices > > > > #Region " Printing Support " > > > > <DllImport("gdi32.DLL", EntryPoint:="BitBlt", SetLastError:=True, > > CharSet:=CharSet.Unicode, _ > > > > ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _ > > > > Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As > > Integer, ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight > As > > Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc As Integer, ByVal nYSrc As > > Integer, ByVal dwRop As System.Int32) As Boolean > > > > ' Leave function empty - DLLImport attribute forwards calls to MoveFile to > > > > ' MoveFileW in KERNEL32.DLL. > > > > End Function > > > > > > > > 'Returns the panel as a bitmap > > > > Private Function CapturePanel() As Bitmap > > > > Dim g1 As Graphics = Me.CreateGraphics() > > > > Dim MyImage As Bitmap = New Bitmap(Me.ClientRectangle.Width, > > (Me.ClientRectangle.Height), g1) > > > > Dim g2 As Graphics = Graphics.FromImage(MyImage) > > > > Dim dc1 As IntPtr = g1.GetHdc() > > > > Dim dc2 As IntPtr = g2.GetHdc() > > > > BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, (Me.ClientRectangle.Height), > > dc1, 0, 0, 13369376) > > > > g1.ReleaseHdc(dc1) > > > > g2.ReleaseHdc(dc2) > > > > 'saves image to c drive for testing - comment out for production > > > > 'MyImage.Save("c:\abc.bmp") > > > > Return MyImage > > > > End Function > > > > #End Region > > > > "Newbie Coder" <newbie_coder@pleasespamme.com> wrote in message > > news:uVl8jtFIHHA.4216@TK2MSFTNGP06.phx.gbl... > > > Hello All > > > > > > VB.NET 2003 Code Only (not C#) > > > > > > How do I capture a window by knowing its class name & save it as a jpg > on > > > a > > > button click? Of course the window won't be in focus > > > > > > Any help would be appreciated without Google links please > > > > > > TIA > > > > > > > > > > > >
ANN: VS2005 SP1
Problem with a modal dialog box called with VB Nested XML files using Nini How to confirm a Web Page Download is Complete? serialize object to MSDE binary datatype Make form full screen adnanced record sorting Handing a multidimensional Array as parameter Code Question -Second Post DataGridViewComboBox |
|||||||||||||||||||||||