Product Summary
BrowseLC is a class library which allows programmers to quickly create highly functional Windows 95 style list controls. This class library is meant to be used with Microsoft's Visual C++ (vs. 4.2 at minimum). An ActiveX database browser control is also included with this product.
Key Features
  • In-place editing of items.
    No programming needed to edit ALL columns.
  • Highlight Entire Rows (CBrowseLC)
    No programming necessary to get your list control to highlight ENTIRE rows.
  • Sortable Columns (CBrowseLC)
    No programming needed to sort on ALL columns.
  • Browse tables of any size (CBrowseVLC)
    No need to worry about complex programming solutions, arrays, memory limitations etc.
Ease Of Use
A BROWSELC list control can be implemented with as little as one line of code.
Reusability
BROWSELC is available as a class library or an activeX control thereby facilitating implementation of OCBC browser list controls.
Source Code
Source code is available for those who wish to modify or extend the functionality of the classes.
Specifications
  • Programming Language
    Visual C++ version 4.2 at minimum. ActiveX controls can be used with Visual Basic 32 bit versions.
  • Operating System
    Any 32 bit Windows or NT operating system version.
  • Programming Expertise Required
    Novice to professional.
 
Page 1 2
CBrowseLC
The CBrowseLC class is derived from the MFC CListCtrl(). Create a CBrowseLC object to display a list control which highlights entire rows and sorts columns by clicking on headers. Note: This class is meant to be used for smaller tables. While the source code defines a five hundred record limit, even less may be displayed depending on the table structure. ie. A table with many fields will use up more memory, consequently, fewer records will be shown. An MFC CRecordset object is passed as one of the parameters to the constructor. This CRecordset object must be opened prior to be passed a parameter.
Constructor:
CBrowseLC( CRecordset* pSet, CWnd* pWnd, const CRect& pRect, UDF* Fields, CImageList* pImageList = NULL, BOOL bDisplay = TRUE );
Parameters
Parameter Description
pSet Pointer to MFC ODBC CRecordset object
pWnd Parent CWnd
pRect CRect window coordinates
pFields User defined fields see UDF structure. Default is NULL.
pImageList ImageList for icon to be displayed at far left of each row. Default is NULL.
bDisplay Initial show state of the list control. TRUE-show, FALSE-hide. Default = TRUE.

Remarks

Create a database browse list control by calling the constructor with the desired parameters. The list control will be displayed immediately, unless the bDisplay parameter is initially set to FALSE. The display can be toggle on or off with pBrowse->ShowWindow( SW_SHOW) or pBrowse->ShowWindow( SW_HIDE), where pBrowse is a pointer to a CBrowseLC object. See UDF for an explanation of user defined fields. Include the pImageList parameter (see samples) to display an icon in the leftmost section of the first column in every row.
 
Page 1 2
CBrowseVLC
CBrowseVLC objects are created in the same way as CBrowseLC objects. The parameter sets are identical. See CBrowseLC for a discusson on how to use CBrowseVLC.
UDF - User Defined Fields array
To display user defined fields in a BROWSELC object, pass a UDF array to CBrowseLC.

//UDF is a CArray to be filled with DEFFIELDS structures

#define UDF CArray<DEFFIELDS, DEFFIELDS&>
//DEFFIELDS struct to insert into a CArray acting as a paramater for user-defined
//fields.

struct DEFFIELDS
{
CString strFldLabel; //user defined field label
BOOL bCalcField; //Supply calculated field function pointer
union
{
LPCSTR lpszFldName; //Actual field name. Used if bCalcField == FALSE
struct //If bCalcField == TRUE, fill in the DefFunction struct
{
void (*lProc)( LPSTR lpszValue/*Pointer to string to receive calc. field value*/,
CRecordset* pSet = NULL/*Pointer to ODBC recordset object */ ); //function pointer
SDWORD nType; //SQLType, eg. SQL_NUMERIC
int nLen; //Field width
int nDec; //Field decimals, if any

}DefFunction;

}FldInfo;

};

Each element of the UDF array element will contain a structure of the above type for each field, user defined or otherwise. The structure will contain either the actual field name or a user defined field label associated with a pointer to a function which will calculate a value. If a user defined field name is used, set the boolean flag, bCalcField to TRUE, otherwise the list control will display the field contents associated with the actual field name indicated in the structure. See samples.


 
Page 1 2
Quick Sample
//For a description of CBrowseLC parameters, see User Reference.
BOOL CDialogBrowse::OnInitDialog()
{ // Replace CBrowseLC with CbrowseVLC for large tables
   CBrowseLC* m_pBrowse = new CBrowseLC( m_pSet, this, CRect( 5, 5, 186, 70 ) ); // Actually m_pBrowse should be declared as a class member and deleted in the destructor

.....
}
Full Fledged Sample

void CalcPayoff( char* pStr, CRecordset* pSet ); // See df.FldInfo.DefFunction.lProc below

BOOL CDialogBrowse::OnInitDialog()
{
   CDialog::OnInitDialog();
   CBitmap pBitmap; //Needed for the imagelist
   UDF pFlds;
   DEFFIELDS df; //For the UDF parameter
   df.strFldLabel = "Date Updated";
      df.bCalcField = FALSE;
   df.FldInfo.lpszFldName = "UPDATED";
   pFlds.Add( df );

   df.strFldLabel = "Type";
   df.bCalcField = FALSE;
      df.FldInfo.lpszFldName = "TYPE";
   pFlds.Add( df );

   df.strFldLabel = "Payoff";
   df.bCalcField = TRUE;
   df.FldInfo.DefFunction.lProc = CalcPayoff; //See CalcPayoff function defined below
   df.FldInfo.DefFunction.nType = SQL_DOUBLE;
   df.FldInfo.DefFunction.nLen = 10;
   df.FldInfo.DefFunction.nDec = 0;
   pFlds.Add( df );

Page 1 2
Full Fledged Sample
m_pSet = new CPROJWIZAnalysisSet(); //a CRecordSet set derivitive

CBrowseLC* m_pBrowse = new CBrowseLC( m_pSet, this, CRect( 5, 5, 186, 70 ), &pFlds, pImageList, FALSE );
// Replace CBrowseLC with CbrowseVLC for large tables

m_pBrowseShowWindow( SW_SHOW );

// Actually m_pBrowse should be declared as a class member and
// deleted in the destructor
}
/* The function defined below is used to display a calculated field. For this field, set df.bCalcField = TRUE. Set a pointer to this function. eg. df.FldInfo.DefFunction.lProc = CalcPayoff as
shown above. */

void CalcPayoff( char* pszFld, CRecordset* pRecSet )
{
   CPROJWIZAnalysisSet* pSet = (CPROJWIZAnalysisSet*)pRecSet;
   char szHold[10];
   double dCalc =
   ( m_pSet->m_SP1 * pSet->m_RETURN1 ) +
   ( m_pSet->m_SP2 * pSet->m_RETURN2 ) +
   ( m_pSet->m_SP3 * pSet->m_RETURN3 ) +
   ( m_pSet->m_SP4 * pSet->m_RETURN4 ) +
   ( m_pSet->m_SP5 * pSet->m_RETURN5 ) +
   ( m_pSet->m_SP6 * pSet->m_RETURN6 ) +
   ( m_pSet->m_SP7 * pSet->m_RETURN7 );

   ltoa( dCalc, szHold, 10 );
   lstrcpy( pszFld, szHold );
}

Class library and ActiveX controls written by Christopher Remington
Copyright © 1996-2000 Strategic Concepts & Innovations Inc. All rights reserved.
Information in this document is subject to change without notice.
Other products and companies referred to herein are trademarks or registered trademarks of their respective companies or mark holders.