BCX_LISTBOX function

Purpose: BCX_LISTBOX creates a listbox that sorts strings in the list box alphabetically. The parent window receives an input message whenever the user clicks or double-clicks a string. The list box has borders on all sides.


 Syntax:

 hCtl = BCX_LISTBOX(Text$, _
                hWndParent, _
                   hCtlID%, _
                     Xpos%, _
                     Ypos%, _
                    Width%, _
                   Height%  _
               [,WinStyle%] _
             [,ExWinStyle%])

 Parameters:

  • hCtl The return value is a handle to the new listbox if the function succeeds. If the function fails, the return value is NULL.
  • Text$ Not used.
  • hWndParent Handle to the parent window of the listbox being created.
  • hCtlID% Specifies the identifier of the listbox being created. The identifier is an integer value used by the listbox being created to notify its parent about events. The identifier must be unique for each listbox created with the same parent window.
  • Xpos% Specifies the initial horizontal position of the listbox being created. X% is the x-coordinate of the upper-left corner of the listbox being created relative to the upper-left corner of the parent window's client area.
  • Ypos% Specifies the initial vertical position of the listbox being created. Y% is the initial y-coordinate of the upper-left corner of the listbox 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 listbox being created.
  • Height% Specifies the height, in device units or, if the PIXELS optional parameter was specified in the GUI statement, in pixels , of the listbox being created.
  • WinStyle% [OPTIONAL] If the WinStyle% parameter is used, the default Window Style for a BCX_LISTBOX control, LBS_STANDARD | WS_CHILD | WS_VISIBLE | LBS_SORT | WS_VSCROLL | WS_TABSTOP, is replaced with the value in WinStyle%. Specifying a WinStyle% of NOSORT causes the resulting ListBox control to not sort its contents. During translation, BCX replaces NOSORT with "WS_CHILD | WS_VISIBLE | WS_VSCROLL". 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_LISTBOX control is WS_EX_CLIENTEDGE. See your Win32 SDK or PSDK Reference help for more information about valid Extended Window Styles.

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

Here is a complete example using the BCX_LISTBOX function.


 GUI "EZIDEPROG", PIXELS

 GLOBAL Form1 AS HWND
 GLOBAL List1 AS HWND

 CONST ID_Form1 = 0
 CONST ID_List1 = 1

 SUB FORMLOAD
   Form1 = BCX_FORM("Form1", 102, 88, 396, 338)
   List1 = BCX_LISTBOX("", Form1, ID_List1, 72, 52, 236, 204)
 
 '**************************************************************************
   SendMessage(List1, LB_ADDSTRING,0,"Annealed Glass")
   SendMessage(List1, LB_ADDSTRING,0,"Themerally Tempered Glass")
   SendMessage(List1, LB_ADDSTRING,0,"Polycarbonate")
   SendMessage(List1, LB_ADDSTRING,0,"Laminated Themerally Tempered Glass")
   SendMessage(List1, LB_ADDSTRING,0,"Laminated Semi-Tempered Glass")
   SendMessage(List1, LB_ADDSTRING,0,"Laminated Annealed Glass")
 '************************************************************************** 
 
  CENTER(Form1)
  SHOW  (Form1)
 END SUB

 BEGIN EVENTS
 SELECT CASE CBMSG
 CASE WM_COMMAND
 IF CBCTL = ID_List1 THEN
 IF CBCTLMSG = LBN_SELCHANGE THEN
 Call List1_Click(ID_List1)
 EXIT FUNCTION
 END IF
 END IF
 END SELECT
 END EVENTS

 SUB List1_Click(Id AS INTEGER)
   DIM RAW hWnd AS HWND
   DIM RAW cSel, Buffer$
   hWnd = GetDlgItem(Form1,Id)
   cSel = SendMessage(hWnd,LB_GETCURSEL,0,0)
   Buffer$ = SPACE$(255)
   SendMessage(hWnd,LB_GETTEXT,cSel,Buffer$)
   SetWindowText(Form1, Buffer$)
 END SUB  'List1_Click

For another example of the BCX_LISTBOX function see Demo.bas in the BCX\Gui_Demo\EZ_Gui folder.

Also the Listbox.Bas file at

http://tech.groups.yahoo.com/group/BCX/files/Win32_API_Snippets/

contains many examples of ListBox wrappers for WinAPI ListBox functions.