Private Declare Function BitBlt Lib "gdi32.dll" Alias "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 Int32 Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As IntPtr) As IntPtr
Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, Nothing) Dim g1 As Graphics = Graphics.FromHdc(dc1) Dim MyImage As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1) PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height) Dim g2 As Graphics = Graphics.FromImage(PictureBox1.Image) dc1 = g1.GetHdc Dim dc2 As IntPtr = g2.GetHdc()
以前質問した問題が解決したのですが、過去ログに移動し返信できなくなったため新規登校させていただきます。
過去ログ
http://dobon.net/cgi-bin/vbbbs/cbbs.cgi?mode=al2&namber=1004&rev=&no=0&KLOG=3
Odagirizmさんに教えていただいたURLを参考に無事解決しました。
参考までにサンプルソースを以下に掲載します。
Private Declare Function BitBlt Lib "gdi32.dll" Alias "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 Int32
Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As IntPtr) As IntPtr
Dim dc1 As IntPtr = CreateDC("DISPLAY", Nothing, Nothing, Nothing)
Dim g1 As Graphics = Graphics.FromHdc(dc1)
Dim MyImage As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g1)
PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height)
Dim g2 As Graphics = Graphics.FromImage(PictureBox1.Image)
dc1 = g1.GetHdc
Dim dc2 As IntPtr = g2.GetHdc()
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc1, 100, 100, 13369376)
g1.ReleaseHdc(dc1)
g2.ReleaseHdc(dc2)
以上