Presented ActiveX control encapsulates spreadsheet functionality and is very similar to
MS FlexGrid control. Why I decided to create my own control? The answer is obvious: because
I didn’t like existing. Users of my projects are mainly accountants with relatively weak
hardware: 486s with 8-12MB RAM. MS FlexGrid works on this platform, but scrolls too slowly to
be convenient.
Presented ActiveX control was implemented using ATL 2.0 and VC++ 5 SP3. It has relatively small
executable size (approximately 55 KB + 22 KB atl.dll instead of 223 KB of MS FlexGrid) and much
higher scrolling speed than MS FlexGrid. Also it supports inplace text editing in cells. Of
course it does not implement many MS FlexGrid’s features – such as cell merging, custom effects
for text etc. But it has enough features to work in real projects. Also because of it’s small
size LiteGrid control can be used in HTML pages.
Properties | ||
Name | Type | Description |
FixedRows | long | Number of fixed rows in the grid |
FixedCols | long | Number of fixed columns in the grid |
Rows | long | Number of rows in the grid |
Cols | long | Number of columns in the grid |
CellText(r,c) | BSTR | Contents of any cell within the grid. r – row, c – column (Rows and columns start with 0) |
ColWidth(c) | long | Width of a column in the grid in pixels. c – column number |
RowHeight(r) | long | Height of a column in the grid in pixels. r – row number |
DefaultColWidth | long | Default width of a column in pixels. When new columns added to the grid, their width is set to this value |
DefaultRowHeight | long | Default height of a row in pixels. When new rows added to the grid, their height is set to this value |
Row | long | The row of currently selected (active) cell |
Col | long | The column of currently selected (active) cell |
FixedFont | LPFONTDISP | Font which is used to draw fixed cells |
NormalFont | LPFONTDISP | Font which is used to draw normal cells |
FixedBkColor | OLE_COLOR | Color of fixed cell’s background |
NormalColor | OLE_COLOR | Color of normal cell’s background |
FixedTextColor | OLE_COLOR | Color of text in fixed cells |
NormalTextColor | OLE_COLOR | Color of text in normal cells |
FixedLightColor | OLE_COLOR | Color of a fixed cell’s light edge |
FixedShadowColor | OLE_COLOR | Color of a fixed cell’s shadow edge |
NormalLightColor | OLE_COLOR | Color of a normal cell’s light edge |
NormalShadowColor | OLE_COLOR | Color of a normal cell’s shadow edge |
CellTop | long | Top coordinate of the selected cell in pixels. Read only |
CellLeft | long | Left coordinate of the selected cell in pixels. Read only |
CellWidth | long | Width of the selected cell in pixels. Read only |
CellHeight | long | Height of the selected cell in pixels |
ResizeRows | VARIANT_BOOL | Enables/disables rows resizing with mouse |
ResizeCols | VARIANT_BOOL | Enables/disables columns resizing with mouse |
Editable | VARIANT_BOOL | Enables/disables inplace editing |
ScrollBars | SCROLL_BAR_TYPE | Changes scroll bars set (lgBothScrollBars, lgHorzScrollBar, lgVertScrollBar, lgNonScrollBars) |
FastDraw | VARIANT_BOOL | Enables/disables grid changes buffering for fast scrolling (if this option turned on (TRUE) LiteGrid shows three times faster scrolling then MS FlexGrid, if not – only 25-30% faster than MS FlexGrid. These results were achieved on P133, S3 Trio. Grids had 1000 rows, 20 columns (9 visible) |
ColAlign(c) | lgColAlignType | Align of text in a column. c – column number. Can be lgAlignLeft, lgAlignCenter, lgAlignRight. |
DefaultColAlign | lgColAlignType | Default align of text in a column. When new columns are added to the LiteGrid, they have this text align. |
Methods | ||
Name | Return type | Description |
GetFixedTextWidth(bsText) | long | Returns width in pixels of BSTR bsText for fixed cells |
GetNormalTextWidth(bsText) | long | Returns width in pixels of BSTR bsText for normal cells |
Events | |
Name | Description |
MouseMove | See VB documentation for this event. Coordinates are given in pixels |
MouseDown | See VB documentation for this event. Coordinates are given in pixels |
Click | See VB documentation for this event |
KeyDown | See VB documentation for this event |
KeyUp | See VB documentation for this event |
KeyPress | See VB documentation for this event |
CellChanging | (r,c) Fired before active cell changes. r indicates new row of selected cell, c – new column |
CellChanged | Fired after active cell has changed |
StartEditing(*b) | Fired before inplace editing. you can assign *b (VARIANT_BOOL type) FALSE to disallow this editing |
EndEditing(bs,*b) | Fired after inplace editing, but before entered text has moved to selected cell. bs (BSTR type) has text string which a user just typed into inplace editor, you also can assign *b (VARIANT_BOOL type) FALSE to prevent writing this data to cell. |
I hope that this control can be useful for many programmers, and you can freely use it in your
projects. Drawing speed can be even more improved by using Poly… GDI functions instead of
single calls: MS promises much faster drawing speed when using these functions.
And at last, if you have suggestions, notes or bug reports please contact me at chandiv@users.univers.cv.ua
or ivannikov@altavista.net (the first address will be closed soon)