BCX_SET_EDIT_COLOR function

Purpose:

BCX_SET_EDIT_COLOR will set the colors in a BCX_EDIT control to the arguments in the RGBforeground and RGBbackground parameters.

Syntax 1:

hBrush = BCX_SET_EDIT_COLOR(HandleToBCX_EditControl AS HWND, _
                                  RGBforeground AS COLORREF, _
                                  RGBbackground AS COLORREF)

Syntax 2:

hBrush = BCX_SET_EDIT_COLOR HandleToBCX_EditControl AS HWND, _
                                  RGBforeground AS COLORREF, _
                                  RGBbackground AS COLORREF

Return Value:

  • Data type: HBRUSH
    HBrush The handle to a logical brush is returned if the function succeeds. The return value is NULL if the function fails.

Parameters:

  • Data type: HWND
    HandleToBCX_EditControl The handle of the BCX_EDIT control to be colored.
  • Data type: COLORREF
    RGBforeground RGB(r,g,b) expression for foreground color of edit control.
  • Data type: COLORREF
    RGBbackground RGB(r,g,b) expression for background color of edit control.

Remarks:

👉 BCX_SET_EDIT_COLOR must be placed inside the BEGIN EVENTS ... END EVENTS loop.

Also see QBCOLOR for an alternative to using the RGB macro.

Example:

GUI "MiniEd"

SUB FORMLOAD
  GLOBAL Form1            AS CONTROL
  GLOBAL Edit1            AS CONTROL
  GLOBAL Button1          AS CONTROL

  '******************************************************************** 
  Form1   = BCX_FORM ( "Mini-Editor",              0,  0, 125, 105)
  Edit1   = BCX_EDIT ( " BCX rocks!", Form1, 101,  5, 20, 105, 60)
  Button1 = BCX_BUTTON( "Change Font", Form1, 102, 35,  3,  40, 13)
  '******************************************************************** 
  CENTER(Form1)       ' Center our Form on the screen 
  SHOW (Form1)       ' Display our creation! 
END SUB

BEGIN EVENTS
  SELECT CASE CBMSG
    '******************************************************************** 
  CASE WM_COMMAND
    '******************************************************************** 
    IF CBCTL = 102 THEN
      CALL SetCustomFont()
    END IF

    '******************************************************************** 
  CASE WM_CTLCOLOREDIT
    '******************************************************************** 
    IF (HANDLE)lParam = Edit1 THEN
      BCX_SET_EDIT_COLOR(Edit1, BCX_Font.RGB, QBCOLOR(31))
    END IF

    '******************************************************************** 
  CASE WM_CLOSE
    '******************************************************************** 
    LOCAL id
    id = MSGBOX("Are you sure?", _
                "Quit Program!", _
    MB_YESNO OR MB_ICONQUESTION)
    IF id = IDYES THEN DestroyWindow(hWnd)
    EXIT FUNCTION
  END SELECT
END EVENTS

SUB SetCustomFont ()
  DIM RetVal

  RetVal = BCX_FONTDLG      ' Fill the BCX_FONT structure 
 IF RetVal THEN
   BCX_SET_FONT(Edit1, BCX_Font.Name$, _
                        BCX_Font.Size, _
                        BCX_Font.Bold, _
                      BCX_Font.Italic, _
                   BCX_Font.Underline, _
                   BCX_Font.Strikeout)
 END IF
END SUB

For another example of the BCX_SET_EDIT_COLOR function see FontDemo.bas.