BCX_FLOODFILL function

Purpose : The BCX_FLOODFILL function fills an area with a specified color.


 Syntax:

 RetVal% = BCX_FLOODFILL(hWnd, _
                         Xpos%, _
                         Ypos%, _
                      FTcolor%, _
                    Fillcolor%  _
                   [, DrawHDC] _
                 [, FillType%])                   

 Parameters:

  • hWnd Identifies the window where the area color fill takes place.
  • Xpos% X-coordinate of the starting point for the area color fill.
  • Ypos% Y-coordinate of the starting point for the area color fill.
  • FTcolor% is an integer representing a RGB color code.
    • If the optional FillType% parameter is not defined or defined as 0, the FTcolor% parameter specifies the RGB color value of the boundary of the fill area.
    • If the optional FillType% parameter is defined as 1, the FTcolor% parameter specifies the RGB color value of the pixels to be changed in the fill area. The area will be filled as long as the color of an adjacent pixel is that specified by the color value of the FTColor% parameter.
  • Fillcolor% is an integer representing the RGB color code of the fill color.
  • DrawHDC [OPTIONAL] is a HDC(Handle to Device Context) pointing to an already open HDC. This is useful if a device context is to be written to many times. In this case the programmer is responsible for closing the HDC at the appropriate time.
  • FillType% [OPTIONAL]
    • 0 is the default value for this parameter. The area is filled until the boundary, specified by the color value of the FTColor% parameter, is reached. For more detail see the documentation for the FLOODFILLBORDER value of the fuFillType parameter of the Microsoft Windows GDI ExtFloodFill function.
    • 1 is the optional value for this parameter. The area will be filled as long as the color of an adjacent pixel is that specified by the color value of the FTColor% parameter. For more detail see the documentation for the FLOODFILLSURFACE value of the fuFillType parameter of the Microsoft Windows GDI ExtFloodFill function.

 Return Value:

  • RetVal% is a nonzero integer if the function succeeds, zero if the function fails.

Here is an example of the BCX_FLOODFILL function.


 GUI "BCX_BlackBall"
   
 CONST IDC_BM1 = 101
 
 GLOBAL RetVal%
 GLOBAL Form1 AS HWND
 GLOBAL Button1 AS HWND
 GLOBAL Button2 AS HWND
 GLOBAL Button3 AS HWND
 GLOBAL Canvas AS HWND
   
 SUB FORMLOAD
   DIM RAW hDestDC AS HDC
   Form1 = BCX_FORM ("BCX_BlackBall", 0, 0, 200, 120)
   Canvas = BCX_BITMAP(0, Form1, IDC_BM1, 5, 5, 105, 105)
   Button1 = BCX_BUTTON("Fill Blue Center", Form1, 1, 115, 5, 75, 15)
   Button2 = BCX_BUTTON("Fill To Red Background", Form1, 2, 115, 20, 75, 15)
   Button3 = BCX_BUTTON("Restore Target", Form1, 3, 115, 35, 75, 15)
   hDestDC = STARTDRAW(Canvas)
   RetVal% = BCX_RECTANGLE(Form1, 11, 11, 200, 200, QBCOLOR(12), 1, hDestDC)
   RetVal% = BCX_CIRCLE(Form1, 110, 110, 60, QBCOLOR(14), 1, hDestDC)
   RetVal% = BCX_CIRCLE(Form1, 110, 110, 40, QBCOLOR(9), 1, hDestDC)
   ENDDRAW (Canvas, hDestDC)  
   CENTER (Form1)
   SHOW (Form1)
 END SUB
   
 BEGIN EVENTS
   SELECT CASE CBMSG
   CASE WM_COMMAND
   
     SELECT CASE CBCTL
 
     CASE 1
       DIM RAW hDestDC AS HDC
       hDestDC = STARTDRAW(Canvas)
       '  To fill the blue center with black
       RetVal% = BCX_FLOODFILL(Form1, 110, 110, QBCOLOR(9), QBCOLOR(0), hDestDC, 1) 
       ENDDRAW (Canvas, hDestDC)
 
     CASE 2
       DIM RAW hDestDC AS HDC
       hDestDC = STARTDRAW(Canvas)
       '  To fill to red background with black
       RetVal% = BCX_FLOODFILL(Form1, 110, 110, QBCOLOR(12), QBCOLOR(0), hDestDC) 
       ENDDRAW (Canvas, hDestDC)
 
     CASE 3
       DIM RAW hDestDC AS HDC
       hDestDC = STARTDRAW(Canvas)
       RetVal% = BCX_RECTANGLE(Form1, 11, 11, 200, 200, QBCOLOR(12), 1, hDestDC)
       RetVal% = BCX_CIRCLE(Form1, 110, 110, 60, QBCOLOR(14), 1, hDestDC)
       RetVal% = BCX_CIRCLE(Form1, 110, 110, 40, QBCOLOR(9), 1, hDestDC)
       ENDDRAW (Canvas, hDestDC)
 
     END SELECT
 
   CASE WM_CLOSE
     DestroyWindow(Form1)
     EXIT FUNCTION
   
   END SELECT
 END EVENTS