' This code is licensed according to the terms and conditions listed here.
' Draw a solid green ellipse on window Form1 and fill
' the area outside of it with a diagonally cross-hatched red brush.
Dim hPen As Long, hBrush As Long ' handles to the pen and brush to be used
Dim hOldPen As Long, hOldBrush As Long ' handles to the previously selected objects
Dim retval As Long ' return value
' Create a solid green pen with a width of one pixel.
hPen = CreatePen(PS_SOLID, 0, RGB(0, 255, 0))
' Select it for use in Form1, noting the previous pen.
hOldPen = SelectObject(Form1.hDC, hPen)
' Create a blue diagonally cross-hatched brush.
hBrush = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 0, 255))
' Select it for use in Form1, noting the previous brush.
hOldBrush = SelectObject(Form1.hDC, hBrush)
' Draw an ellipse with bounding rectangle (100,150)-(350, 250)
retval = Ellipse(Form1.hDC, 100, 150, 350, 250)
' Flood fill the area outside the ellipse (use a green boundary)
' starting at the point (25,30) outside the ellipse.
retval = ExtFloodFill(Form1.hDC, 25, 25, RGB(0, 255, 0), FLOODFILLBORDER)
' Select the previously selected pen and brush.
retval = SelectObject(Form1.hDC, hOldPen)
retval = SelectObject(Form1.hDC, hOldBrush)
' Delete the pen and brush to free up resources.
retval = DeleteObject(hPen)
retval = DeleteObject(hBrush)