>また、Paint 内での描画内容が固定的な場合は、Paint をその都度処理する代わりに、 >予め Bitmap に描画しておいて、それを PictureBox に表示した方が楽かもしれません。 固定的なものてはではなく「子供達のための「お絵かき」を作ろうと思っています。 デバイスコンテキストを得るための手法につきましては、完全に行き詰まっています。具体的なヒントを頂ければと存じます。 Imports System.Runtime.InteropServices Public Class Form1 Private Declare Function ExtFloodFill Lib "gdi32" ( _ ByVal hdc As IntPtr, _ ByVal x As Integer, _ ByVal y As Integer, _ ByVal crColor As Integer, _ ByVal wFillType As UInteger) As Boolean Private Declare Function CreateBrushIndirect Lib "gdi32" (ByRef lpLogBrush As LOGBRUSH) As IntPtr Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As IntPtr) As IntPtr Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As IntPtr, _ ByVal hObject As Integer) As <MarshalAs(UnmanagedType.Bool)> Boolean Private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer) As Integer Private Declare Function CreateCompatibleDC Lib "gdi32" Alias "CreateCompatibleDC" (ByVal hdc As IntPtr) As IntPtr Private Const FLOODFILLBORDER As UInteger = 0 'UI Private Const FLOODFILLSURFACE As UInteger = 1 'UI Private Structure LOGBRUSH Public lbStyle As Integer Public lbColor As Integer Public lbHatch As Integer End Structure Dim oldX, oldY As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'PictureBox1.Refresh() PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height) End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove '---- 自由ラインを描く ---- 閉じた図形とする If e.Button = System.Windows.Forms.MouseButtons.Left Then Dim g As Graphics = Graphics.FromImage(PictureBox1.Image) Dim myPen As New Pen(Color.Green, 2) g.DrawLine(myPen, oldX, oldY, e.X, e.Y) PictureBox1.Image = PictureBox1.Image g.Dispose() PictureBox1.Refresh() 'Invalidate() End If oldX = e.X : oldY = e.Y End Sub Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown '----- 塗りつぶしは マウス 右クリック ------- Dim g As Graphics = PictureBox1.CreateGraphics If e.Button = System.Windows.Forms.MouseButtons.Right Then Dim hDC As Long = g.GetHdc() 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) g.ReleaseHdc() hNewBrush = SelectObject(hDC, hOldBrush) DeleteObject(hNewBrush) End If g.Dispose() End Sub End Class