BCX_SETCOLOR statement

Purpose: BCX_SETCOLOR sets the foreground and background color of a HDC handle to a device context of a HWND handle to a control. Note well that this function is limited to use only with static and edit controls. It does not work with button controls.


 Syntax:
 BCX_SETCOLOR(ForegroundRGBColor, _
               BackgroundRGBColor, _
                     [, hDC, hWnd])

 Parameters:

  • ForegroundRGBColor RGB(r,g,b) expression for foreground color to be set.
  • BackgroundRGBColor RGB(r,g,b) expression for background color to be set. This parameter can be set to -1 for a transparent background.
  • hDC [OPTIONAL] The handle to a device context(HDC) on which the colors are to be set.The argument for this parameter is automatically added if only the foreground and background color is given.
  • hWnd [OPTIONAL] The handle to the control(HWND) containing the HDC on which the colors are to be set.The argument for this parameter is automatically added if only the foreground and background color is given.

Example:


 GUI "BCX_SETCOLOR"
 
 GLOBAL Form1 AS HWND
 GLOBAL hStc1 AS CONTROL
 GLOBAL hStc2 AS CONTROL
 
 SUB FORMLOAD()
   Form1 = BCX_FORM("BCX_SETCOLOR", 0, 0, 110, 110)
   hStc1 = BCX_LABEL("File List",Form1, 1000, 7, 12, 40, 16)
   hStc2 = BCX_LABEL("File List",Form1, 1001, 7, 30, 40, 16)
   BCX_SET_FORM_COLOR(Form1, RGB(0,0,250))
 
   CENTER(Form1)
   SHOW(Form1)
 END SUB
 
 BEGIN EVENTS
   SELECT CASE CBMSG
   CASE WM_CTLCOLORSTATIC
     IF hStc1 = (HWND)CBLPARAM THEN
       FUNCTION = BCX_SETCOLOR(RGB(255,0,0), -1)
     END IF
     IF hStc2 = (HWND)CBLPARAM THEN
       FUNCTION = BCX_SETCOLOR(RGB(0,0,0), RGB(255,255,255))
     END IF
   END SELECT
 END EVENTS