BCX_LISTVIEW function

Purpose:

BCX_LISTVIEW creates a listview control.

Syntax:

hCtl = BCX_LISTVIEW(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] _
              [,NumCols AS INTEGER])

Return Value:

  • Data type: HWND
    hCtl The handle of the new listview 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 listview being created.
  • Data type: INTEGER
    hCtlID Specifies the identifier of the listview being created. The identifier is an integer value used by the listview being created to notify its parent about events. The identifier must be unique for each listview 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 listview 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 listview 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 listview 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 listview being created.
  • Data type: INTEGER
    WinStyle [OPTIONAL] If the WinStyle parameter is used, the default Window Style for a BCX_LISTVIEW control, WS_CHILD | WS_TABSTOP | WS_VISIBLE | 0x241 | WS_BORDER, is replaced with the value in WinStyle. For more information, visit the Microsoft Window Styles webpage.
  • Data type: INTEGER
    ExWinStyle [OPTIONAL] The default window Extended Window Style for a BCX_LISTVIEW control is WS_EX_CLIENTEDGE. For more information, visit the Microsoft Extended Window Styles webpage.
  • Data type: INTEGER
    NumCols [OPTIONAL] specifies the number of columns to be used in the listview being created. If this parameter is not specified, the number of columns will default to 15.

Remarks:

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

Grid lines cannot be removed from BCX_LISTVIEW using the MODSTYLE function, so here is an example that shows how the grid lines can be removed.

hList = BCX_LISTVIEW("", HndlWnd, IDC_LIST, 3, 16, 407, 189, List_Styles, ListEx_Styles, 0)
MACRO NOGRIDLINES = LVS_EX_FULLROWSELECT
SendMessage(hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0,NOGRIDLINES)

LVM_SETEXTENDEDLISTVIEWSTYLE allows you to manipulate the styles similar to BCX's MODSTYLE. Here is a little wrapper that will add or remove styles without having to know the existing styles or unintentionally changing the existing styles.

SUB ModStyleLVEX OPTIONAL(HndlWnd AS HWND, addstyle, remstyle=0)
  SendMessage(HndlWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, addstyle|remstyle, addstyle)
END SUB

Here is a test call for the above wrapper.

ModStyleLVEX( hList, LVS_EX_FLATSB|LVS_EX_HEADERDRAGDROP, LVS_EX_GRIDLINES)

For an example of the BCX_LISTVIEW function see Demo.bas.