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$, _
              hWndParent, _
                 hCtlID%, _
                   Xpos%, _
                   Ypos%, _
                  Width%, _
                 Height%  _
             [,WinStyle%] _
           [,ExWinStyle%])

 Parameters:

  • hCtl The return value is a handle to the new radio button if the function succeeds. If the function fails, the return value is NULL.
  • Text$ Label for the radio button.
  • hWndParent Handle to the parent window of the radio button being created.
  • 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.
  • Xpos% Specifies the initial horizontal position of the radio button being created. X% is the x-coordinate of the upper-left corner of the radio button being created relative to the upper-left corner of the parent window's client area.
  • Ypos% Specifies the initial vertical position of the radio button being created. Y% is the initial y-coordinate of the upper-left corner of the radio button being created relative to the upper-left corner of the parent window's client area.
  • 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.
  • 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.
  • 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%. See your Win32 SDK or PSDK Reference help for more information about valid Window Styles.
  • ExWinStyle% [OPTIONAL] The default Extended Window Style for a BCX_RADIO control is 0. See your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.

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

Here is a demo program of the BCX_RADIO function.


 GUI  "RadioGUI" , PIXELS
 DIM Form1        AS  CONTROL
 DIM Group1       AS  CONTROL
 DIM GroupA       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("RadioButtons", 0, 0, 300, 300)

 Group1 = BCX_GROUP("", Form1, 100, 10, 10, 100, 120, WS_GROUP | WS_CHILD | WS_VISIBLE | BS_GROUPBOX)

 RadioX[0] = BCX_RADIO("0", Form1, 101, 20, 20, 70, 20)
 RadioX[1] = BCX_RADIO("1", Form1, 102, 20, 50, 70, 20)
 RadioX[2] = BCX_RADIO("2", Form1, 103, 20, 80, 70, 20)
 GroupA = BCX_GROUP("", Form1, 104, 190, 10, 100, 120, WS_GROUP | WS_CHILD | WS_VISIBLE | BS_GROUPBOX)

 RadioX[3] = BCX_RADIO("3", Form1, 105, 200, 20, 70, 20)
 RadioX[4] = BCX_RADIO("4", Form1, 106, 200, 50, 70, 20)
 RadioX[5] = BCX_RADIO("5", Form1, 107, 200, 80, 70, 20)
 Label = BCX_LABEL("CBCTL", Form1, 108, 100, 200, 100, 20, WS_CHILD | WS_VISIBLE | WS_GROUP | SS_LEFT)

 TheButton = BCX_BUTTON("Which RadioButtons are checked ?", Form1, 109, 45, 150, 200, 20)

 SetFocus(RadioX[0])
 SHOW(Form1)

 END SUB

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

       CASE 101,102,103,105,106,107
       BCX_SET_TEXT(Label,str$(CBCTL))

       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$ & "Radio[" & 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