Private Declare Function FloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
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
Private Sub Command2_Click()
Picture1.ScaleMode = 3
Picture1.Line (50, 50)-(300, 100)
Picture1.Line (300, 100)-(250, 300)
Picture1.Line (250, 300)-(50, 200)
Picture1.Line (50, 200)-(50, 50)
Dim hBrush As Long
Dim hOldBrush As Long
hBrush = CreateSolidBrush(RGB(255, 0, 0))
hOldBrush = SelectObject(Picture1.hdc, hBrush)
FloodFill Picture1.hdc, 100, 100, RGB(0, 0, 0)
SelectObject Picture1.hdc, hOldBrush
DeleteObject hBrush
End Sub
用API
Public Declare Function CreatePolyPolygonRgn Lib "gdi32" Alias "CreatePolyPolygonRgn" (lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
创建区域,
用
Public Declare Function FillRgn Lib "gdi32" Alias "FillRgn" (ByVal hdc As Long, ByVal hRgn As Long, ByVal hBrush As Long) As Long
填充颜色