塗りつぶし
ここに載せてあるソースコードは、参考のために載せてあります
サンプルコードは、一番下にLZHとしてあります
Option Explicit '塗りつぶし Private Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long Const FLOODFILLSURFACE = 1 '指定された色の領域 '色の作成 Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long 'オブジェクトの選択 Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long 'オブジェクトの解放 Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long Dim GetColor As Long '塗りつぶす色を入れる変数 Private Sub Form_Load() GetColor = vbBlue '塗りつぶす色を指定 Picture1.ScaleMode = vbPixels 'Picture1の座標をピクセル Picture1.AutoRedraw = True '継続表示指定 Picture1.Circle (100, 100), 100 '塗りつぶすときの障害物を配置 Picture1.Circle (150, 120), 80 End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim MouseColor, jRet, jHBr MouseColor = Picture1.Point(X, Y) 'マウスの座標上の色を取得 jHBr = CreateSolidBrush(GetColor) '色オブジェクトを作成 SelectObject Picture1.hdc, jHBr 'オブジェクトの選択状態 ExtFloodFill Picture1.hdc, X, Y, MouseColor, FLOODFILLSURFACE '塗りつぶす DeleteObject jHBr 'オブジェクトを解放 End Sub |