BCX_COMBOBOX function

Purpose:

BCX_COMBOBOX creates a combobox that displays a list when the user selects the dropdown button next to the edit control.

Syntax:

hCtl = BCX_COMBOBOX(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 combobox if the function succeeds. If the function fails, the return value is NULL.

Parameters:

  • Data type: STRING
    Text Not used.
  • Data type: HWND
    hwndParent The handle of the parent window of the combobox being created.
  • Data type: INTEGER
    hCtlID Specifies the identifier of the combobox being created. The identifier is an integer value used by the combobox 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 combobox 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 combobox 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 control being created.
  • 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 control being created.
  • Data type: INTEGER
    WinStyle [OPTIONAL] If the WinStyle parameter is used, the default Window Style for a BCX_COMBOBOX control, WS_CHILD | WS_VISIBLE | CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP, is replaced with the value in WinStyle. For more information, visit the Microsoft ComboBox Control Styles webpage and the Microsoft Window Styles webpage.
  • Data type: INTEGER
    ExWinStyle [OPTIONAL] The default Extended Window Style for a BCX_COMBOBOX control is WS_EX_CLIENTEDGE. For more information, visit the Microsoft Extended Window Styles webpage.

Remarks:

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

Example:

GUI "EZCombo"

DIM Form1 AS CONTROL
DIM Combo1 AS CONTROL

SUB FORMLOAD
  LOCAL i, A$

  Form1 = BCX_FORM("EZ-GUI BCX_FORM", 0, 0, 155, 50)
  Combo1 = BCX_COMBOBOX("Not used placeholder", Form1, 108, 5, 5, 140, 35)

  FOR i = 97 TO 97 + 25
    A$ = "ComboBox item " & UCASE$(CHR$(i))
    SendMessage(Combo1, CB_ADDSTRING, 0, A$)
  NEXT

  CENTER(Form1)
  SHOW(Form1) ' Show it! 
END SUB

BEGIN EVENTS
  SELECT CASE CBMSG
  CASE WM_LBUTTONDOWN
    SetWindowText(Form1, "Left Button Down")
    EXIT FUNCTION

  CASE WM_LBUTTONUP
    SetWindowText(Form1, "Left Button Up")
    EXIT FUNCTION

  CASE WM_RBUTTONDOWN
    SetWindowText(Form1, "Right Button Down")
    EXIT FUNCTION

  CASE WM_RBUTTONUP
    SetWindowText(Form1, "Right Button Up")
    EXIT FUNCTION

  CASE WM_CLOSE
    DestroyWindow(Form1)
    EXIT FUNCTION

  CASE WM_DESTROY
    PostQuitMessage(0)
    EXIT FUNCTION
  END SELECT
END EVENTS

For another example using the BCX_COMBOBOX function see Demo.bas.