BCX_SET_FORM_COLOR statement

Purpose:

BCX_SET_FORM_COLOR will color a Control according to a RGB COLORREF value.

Syntax 1:

BCX_SET_FORM_COLOR HndlWnd AS HWND, Colour AS COLORREF

Syntax 2:

BCX_SET_FORM_COLOR(HndlWnd AS HWND, Colour AS COLORREF)

Parameters:

  • Data type: HWND
    HndlWnd The handle to the Form on which color is to be set.
  • Data type: COLORREF
    Colour A value in the range 0 through 4294967295.

Remarks:

Normally, you only need to use BCX_SET_FORM_COLOR once, so it is best to issue it in SUB FORMLOAD before calling SHOW (YourForm).

👉 Never use BCX_SET_FORM_COLOR directly in the BEGIN EVENTS loop. BCX_SET_FORM_COLOR forces Windows to redraw your Form each time that the command is executed. In any loop, this can lead to severe flicker and other undesirable effects.

👉 For example, never do this!

BEGIN EVENTS
  BCX_SET_FORM_COLOR(Form1, RGB(128,128,128))
END EVENTS

Instead, tie BCX_SET_FORM_COLOR to a particular event, like this:

BEGIN EVENTS
  SELECT CASE WM_COMMAND
  CASE ID_I_WANT_TO_CHANGE_THE_COLORS_NOW
    BCX_SET_FORM_COLOR(Form1, RGB(128,128,128))
  END SELECT
END EVENTS

Example:

GUI "BCX_SET_FORM_COLOR"

SUB FORMLOAD
  GLOBAL Form1 AS HWND
  Form1 = BCX_FORM("BCX_SET_FORM_COLOR", 0, 0, 155, 110)
  BCX_SET_FORM_COLOR(Form1,QBCOLOR(4))
  CENTER(Form1)
  SHOW(Form1)
END SUB

BEGIN EVENTS
  SELECT CASE CBMSG
  CASE WM_CLOSE
    DestroyWindow(Form1)
    EXIT FUNCTION
  END SELECT
END EVENTS