BCX_RADIO function

Purpose:

BCX_RADIO creates a radio control, whose check state is checked and automatically sets the check state for all other buttons in the same group to be cleared.

Syntax:

hCtl = BCX_RADIO(Text AS STRING, _
             hwndParent AS HWND, _
              hCtlID AS INTEGER, _
                Xpos AS INTEGER, _
                Ypos AS INTEGER, _
               Width AS INTEGER, _
              Height AS INTEGER  _
         [, WinStyle AS INTEGER] _
       [, ExWinStyle AS INTEGER])

Return Value:

  • Data type: HWND
    hCtl The handle of the new radio button if the function succeeds. If the function fails, the return value is NULL.

Parameters:

  • Data type: STRING
    Text Label for the radio button.
  • Data type: HWND
    hwndParent The handle of the parent window of the radio button being created.
  • Data type: INTEGER
    hCtlID Specifies the identifier of the radio button being created. The identifier is an integer value used by the radio button being created to notify its parent about events. The identifier must be unique for each control created with the same parent window.
  • Data type: INTEGER
    Xpos Specifies the initial horizontal x-coordinate value of the upper-left corner location of the radio button being created relative to the upper-left corner of the parent window's client area.
  • Data type: INTEGER
    Ypos Specifies the initial vertical y-coordinate value of the upper-left corner location of the radio button being created relative to the upper-left corner of the parent window's client area.
  • Data type: INTEGER
    Width Specifies the width, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels, of the radio button being created. If the width is equal to zero, the radio button will be resized automatically to accommodate the width of the caption.
  • Data type: INTEGER
    Height Specifies the height, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels, of the radio button being created.
  • Data type: INTEGER
    WinStyle [OPTIONAL] If the WinStyle parameter is used, the default Window Style for a BCX_RADIO control, WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_AUTORADIOBUTTON, is replaced with the value in WinStyle. For more information, visit the Microsoft Button Control Styles webpage and the Microsoft Window Styles webpage.
  • Data type: INTEGER
    ExWinStyle [OPTIONAL] The default Extended Window Style for a BCX_RADIO control is 0. For more information, visit the Microsoft Extended Window Styles webpage.

Remarks:

The default window Style for a BCX_RADIO control also can be changed by using the MODSTYLE function.

Example

Here is a demo program of the BCX_RADIO function.

GUI "BCX_RADIO", PIXELS

DIM Form1        AS CONTROL
DIM GroupA       AS CONTROL
DIM GroupB       AS CONTROL
DIM RadioX[6]   AS CONTROL
DIM Label        AS CONTROL
DIM TheButton    AS CONTROL
DIM selitem      AS LONG
DIM str1$
DIM str2$

SUB FORMLOAD

  Form1 = BCX_FORM("BCX_RADIO", 0, 0, 245, 200)

  GroupA    = BCX_GROUP("Group A", Form1, 100, 10, 10, 100, 100)
  RadioX[0] = BCX_RADIO("RadioX0", Form1, 101, 20, 25, 70, 20)
  MODSTYLE(RadioX[0], WS_GROUP)
  RadioX[1] = BCX_RADIO("RadioX1", Form1, 102, 20, 55, 70, 20)
  RadioX[2] = BCX_RADIO("RadioX2", Form1, 103, 20, 85, 70, 20)

  GroupB    = BCX_GROUP("Group B", Form1, 200, 125, 10, 100, 100)
  RadioX[3] = BCX_RADIO("RadioX3", Form1, 104, 135, 25, 70, 20)
  MODSTYLE(RadioX[3], WS_GROUP)
  RadioX[4] = BCX_RADIO("RadioX4", Form1, 105, 135, 55, 70, 20)
  RadioX[5] = BCX_RADIO("RadioX5", Form1, 106, 135, 85, 70, 20)

  TheButton = BCX_BUTTON("Which RadioButtons are checked ?", Form1, 109, 10, 120, 215, 22)

  Label = BCX_LABEL("CBCTL", Form1, 108, 10, 145, 200, 20, WS_CHILD | WS_VISIBLE | WS_GROUP | SS_LEFT)

  SetFocus(RadioX[0])
  CENTER(Form1)
  SHOW(Form1)

END SUB

BEGIN EVENTS
  SELECT CASE CBMSG
    '********************** 
  CASE WM_COMMAND
    '********************** 
    SELECT CASE CBCTL

    CASE 101,102,103,104,105,106
      BCX_SET_TEXT(Label, "Tab at RadioX" & STR$(CBCTL-101, 1))

    CASE 109
      FOR INTEGER i = 0 TO 5
        selitem = SendMessage(RadioX[i], BM_GETCHECK,0,0)
        SELECT CASE selitem
        CASE BST_CHECKED
          str1$ = LTRIM$(STR$(i))
          str2$ = str2$ & "RadioX" & str1$ & " is checked !" & CRLF$
        END SELECT
      NEXT i
      IF str2$ = "" THEN
        str2$ = "No Radio Jammed !"
      END IF
      MSGBOX str2$
      str2$ = ""

    END SELECT
    '********************** 
  CASE WM_CLOSE
    '********************** 
    DestroyWindow(Form1)
  END SELECT
END EVENTS