Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
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
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 Const FLOODFILLBORDER = 0
Private Const FLOODFILLSURFACE = 1
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim point As POINTAPI
Me.Cls
Me.ForeColor = RGB(255, 0, 0)
' draw first ellipse's bounding rectangle
MoveToEx Me.hdc, 10, 10, point
LineTo Me.hdc, 500, 10
LineTo Me.hdc, 500, 300
LineTo Me.hdc, 10, 300
LineTo Me.hdc, 10, 10
' draw first ellipse
Ellipse Me.hdc, 10, 10, 500, 300
Me.ForeColor = RGB(0, 0, 255)
' draw second ellipse's bounding rectangle
MoveToEx Me.hdc, 10, 10, point
LineTo Me.hdc, 300, 10
LineTo Me.hdc, 300, 300
LineTo Me.hdc, 10, 300
LineTo Me.hdc, 10, 10
' draw second ellipse
' because the rectangle is square, a circle is drawn
Ellipse Me.hdc, 10, 10, 300, 300
End Sub
Private Sub Command2_Click()
On Error GoTo ClrError
CommonDialog1.CancelError = True
CommonDialog1.ShowColor
Exit Sub
ClrError:
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
' create solid brush object
brush = CreateSolidBrush(CommonDialog1.Color)
' select it into the current device context
SelectObject Me.hdc, brush
' fill area with selected brush
ExtFloodFill Me.hdc, x, y, Me.point(x, y), FLOODFILLSURFACE