Provides an easy to use virtual listbox implementation. The virtual listbox supports focus tracking, mouse hot tracking items, mouse wheel support, and user selectable coloring in addition to the standard list box features. In addition there's an implementation of logging to a window that allows logging approximately 100,000 items per second. Both include example programs.
Following is some example creation code. Note that the dialog must be shown modelessly at least initially so that WM_MeasureItem will be dispatched correctly. If you forget this, the items will be a default height.
' Create the dialog Dialog New Pixels, 0, "Virtual List Box", , , 300, 500, %WS_OverlappedWindow Or %DS_Center Or %WS_ClipChildren, %WS_Ex_Composited To hDlg ' Put the dialog procedure in place Dialog Show Modeless hDlg Call DlgProc: ' Need to have to proc in place when adding controls ' Add a virtual listbox ControlAddVirtualListBox hDlg, 101, %LIST_ITEM_COUNT, 24, 10, 10, 140, 480 ' After creation you can show the dialog modally if desired Dialog Show Modal hDlg Call DlgProcIn addition you must create a function to provide values to the listbox. For example:
Function GetValueListBox1( ByVal index As Long ) As String ' Dynaically generated Function = "ListBox1 " + Format$( index+1, "#,##0" ) End FunctionFinally you must create a dialog procedure to dispatch a few events:
CallBack Function DlgProc Local l, w, h As Long Select Case Cb.Msg Case %WM_MouseLeave, %WM_DrawItem, %WM_MeasureItem Select Case Cb.WParam Case 101: Function = ListBoxDialogProc( Cb.Hndl, Cb.Msg, Cb.WParam, Cb.LParam, CodePtr( GetValueListBox1 ) ) End Select End Select End Function
The available routines for the virtual listbox are:
Sub ListBoxSetDefaultColors( ByVal foreColor As Dword, ByVal backColor As Dword, ByVal selForeColor As Dword, ByVal selBackColor As Dword, ByVal selUnFocusBackColor As Dword, ByVal hotTrack As Dword )
Sets the colors any subsequent listbox will initially be created with
Sub ListBoxSetColors( ByVal hDlg As Dword, ByVal ctrlId As Long, ByVal foreColor As Dword, ByVal backColor As Dword, ByVal selForeColor As Dword, ByVal selBackColor As Dword, ByVal selUnFocusBackColor As Dword, ByVal hotTrack As Dword )
Sets the current colors for the listbox, may be changed at any time.
Sub ListBoxSetCount( ByVal hDlg As Dword, ByVal ctrlId As Long, ByVal cnt As Long )
Sets the number of items in the list box
Sub ControlAddSimpleListBox( ByVal hDlg As Dword _ , ByVal ctrlId As Long _ , ByVal cnt As Long _ , ByVal itemHeight As Long _ , ByVal x As Long _ , ByVal y As Long _ , ByVal w As Long _ , ByVal h As Long _ , ByVal winStyle As Dword _ , ByVal winStyleEx As Dword _ , ByVal valueProc As Dword )
Sub ControlAddDrawnListBox( ByVal hDlg As Dword _ , ByVal ctrlId As Long _ , ByVal cnt As Long _ , ByVal itemHeight As Long _ , ByVal x As Long _ , ByVal y As Long _ , ByVal w As Long _ , ByVal h As Long _ , ByVal winStyle As Dword _ , ByVal winStyleEx As Dword _ , ByVal drawProc As Dword )
Sub ListBoxGetColors( ByVal hDlg As Dword, ByVal ctrlId As Long, ByVal clr As Long, ByRef fgColor As Dword, ByRef bgColor As Dword )
The available routines for logging are:
Sub LogMessage( msg As String )
Add a message to the log window.
Function NewLogging( openModal As Long ) As Dword
Create a new logging window.