GDI is an abbreviation for Graphics Device Interface. Windows uses GDI32.DLL to accomplish many graphics tasks.
GetDC
A DC is a Device Context. Windows sends graphics commands to a Device Context, so to use API graphics commands from the GDI32.DLL we must first retrieve a device context handle. To get a DC handle, we pass the graphicbox handle to the API function from User32.DLL called GetDC.
h =hwnd(#1.graphicbox)calldll#user32,"GetDC",_
h asulong,_
hdc asulong
ExtFloodFill
Graphic objects can be filled with the ExtFloodFill (extended flood fill) function. It is the same as an older API function called FloodFill, with extra functionality. It looks like this.
' wFillType style flags'_FLOODFILLBORDER (=0)'_FLOODFILLSURFACE (= 1)calldll#gdi32,"ExtFloodFill",_
hdc AsuLong,_ 'device context
x AsLong,_ 'x location to start filling
y AsLong,_ 'y location to start filling
crColor AsLong,_ 'long color value of border, or color to replace
wFillType As Long_'flag for type of fill
result AsLong'nonzero if successful
The first argument for ExtFloodFill is the handle for the graphicbox device contest.
The x and y location to begin the fill are the next arguments. These coordinates are counted from the upper left corner of the graphics area.
The arguments for color and fill type are next. There are two ways to fill an area. With _FLOODFILLBORDER type of fill, the fill area is bounded by the color specified by the crColor parameter. With _FLOODFILLSURFACE type of fill, the fill area is defined by the color that is specified by crColor. Filling continues outward in all directions as long as the color is encountered. This style is useful for filling areas with multicolored boundaries.
Long Color Value
The crColor argument requires an RGB color in one long numeric value. We can create a long color value from the RGB components like this:
FLOOD FILL
-Adapted from:
APIs for Liberty BASIC
FLOOD FILL | GDI | GetDC | ExtFloodFill | Long Color Value
GDI
GDI is an abbreviation for Graphics Device Interface. Windows uses GDI32.DLL to accomplish many graphics tasks.
GetDC
A DC is a Device Context. Windows sends graphics commands to a Device Context, so to use API graphics commands from the GDI32.DLL we must first retrieve a device context handle. To get a DC handle, we pass the graphicbox handle to the API function from User32.DLL called GetDC.
ExtFloodFill
Graphic objects can be filled with the ExtFloodFill (extended flood fill) function. It is the same as an older API function called FloodFill, with extra functionality. It looks like this.
The first argument for ExtFloodFill is the handle for the graphicbox device contest.
The x and y location to begin the fill are the next arguments. These coordinates are counted from the upper left corner of the graphics area.
The arguments for color and fill type are next. There are two ways to fill an area. With _FLOODFILLBORDER type of fill, the fill area is bounded by the color specified by the crColor parameter. With _FLOODFILLSURFACE type of fill, the fill area is defined by the color that is specified by crColor. Filling continues outward in all directions as long as the color is encountered. This style is useful for filling areas with multicolored boundaries.
Long Color Value
The crColor argument requires an RGB color in one long numeric value. We can create a long color value from the RGB components like this: