Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown If e.Button = System.Windows.Forms.MouseButtons.Right Then Dim g As Graphics = Graphics.FromImage(PictureBox1.Image) Dim hWnd As IntPtr = PictureBox1.Handle Dim hdc As IntPtr = GetWindowDC(hWnd) Dim wFillType As UInteger = 1 ' FLOODFILLSURFACE Dim hNewBrush As IntPtr Dim hOldBrush As IntPtr Dim NewBrush As LOGBRUSH NewBrush.lbColor = ColorTranslator.ToWin32(Color.Yellow) NewBrush.lbStyle = 0 NewBrush.lbHatch = 0 hNewBrush = CreateBrushIndirect(NewBrush) hOldBrush = SelectObject(hdc, hNewBrush) ExtFloodFill(hdc, e.X, e.Y, GetPixel(hdc, e.X, e.Y), wFillType) Dim gr As Graphics = Graphics.FromImage(PictureBox2.Image) Dim hDC2 = gr.GetHdc() PictureBox2.Visible = False BitBlt(hDC2, 0, 0, 300, 300, hdc, 0, 0, &HCC0020&) PictureBox1.Image = PictureBox2.Image ReleaseDC(hWnd, hdc) 'デバイスコンテキストを開放する hNewBrush = SelectObject(hdc, hOldBrush) '元のブラシに戻す DeleteObject(hNewBrush) '不要になったブラシを開放する g.Dispose() ReleaseDC(hWnd, hDC2) gr.Dispose() 'ListBox1.Items.Add(hdc) End If End Sub