mCtrl  0.10.0
Data Structures
grid.h File Reference

Go to the source code of this file.

Detailed Description

Grid control (MC_WC_GRID).

The grid control provides user interface for presentation of a lot of data in, as the name of the control suggests, a grid.

Data Model

By default, the control uses MC_HTABLE data model to manage the data displayed by the control. Then, actually, all messages manipulating with data hold by the control just call corresponding function manipulating with the underlying MC_HTABLE.

By default, the control creates an empty table during its creation, of size 0 x 0. So, usually, one of the first messages sent to the control by any application is MC_GM_RESIZE.

Alternatively, you can use the style MC_GS_NOTABLECREATE. In that case the control does not create any table during its creation, and you must associate an existing table with the control with the message MC_GM_SETTABLE. Until you do so, all messages attempting to modify the underlying table will just fail.

MC_GM_SETTABLE together with MC_GM_GETTABLE allows attaching one table to multiple controls.

Messages which do not manipulate with the table determine how the table is presented and these are tied to the control. I.e. if any table is attached to multiple control, each of the controls can present the table in other way (e.g. have another dimensions for each cell etc.).

Virtual Grid

The grid can defer management of the data to the parent window instead of using the MC_HTABLE. To do this, application has to apply the style MC_GS_OWNERDATA.

The control then uninstalls any table currently associated with it (if any), and whenever painting a cell, it asks its parent for the data it needs. The control uses the notification MC_GN_GETDISPINFO to retrieve the data.

The virtual grid is especially useful to present data calculated on the fly or retrieved from some large database, so that only the required amount of the data is calculated and retrieved, which can result in saving a lot of memory and CPU cycles.

The control actually only remembers dimensions of the virtual table as set by MC_GM_RESIZE.

If the retrieval of the data is expensive operation, the application may want to implement some caching scheme. For this purpose the control sends the notification MC_GN_ODCACHEHINT, which informs the application about the region of cells it may ask most frequently. Note however the control is free to ask for any cell, not just the one included in the range as specified by the latest MC_GN_ODCACHEHINT.

Also note that (if the control has the styles MC_GS_COLUMNHEADERNORMAL and/or MC_GS_ROWHEADERNORMAL) the grid may ask for the header cells, although the headers are never explicitly included in MC_GN_ODCACHEHINT.

To force repainting of one or more items, when the underlying data change, the application is supposed to use the message MC_GM_REDRAWCELLS.

Please remember that when the style MC_GS_OWNERDATA is used, some control messages and styles behave differently:

Column and Row Headers

The application can manipulate also with headers of columns and rows. For many purposes, the control treats them as any ordinary cells, but of course there are also differences.

The header cells have to be addressed by special index MC_TABLE_HEADER. Column header uses index of the column of interest and row index MC_TABLE_HEADER and, similarly, row header uses column header MC_TABLE_HEADER and the row index.

For example, to get or set contents of header cells, the application can use exactly the same messages as for ordinary cells, i.e. messages MC_GM_GETCELL and MC_GM_SETCELL respectively, where one of the indexes is set to MC_TABLE_HEADER.

Selection

The grid control supports four distinct selection modes. These modes determine how the cells may or may not be selected:

The mode influences how the control reacts on mouse and keyboard events with respect to the selection, and also how the control processes various selection related messages and notifications.

Note that the selection may also be changed with keyboard only if the style ref MC_GS_FOCUSEDCELL is also used.

Focused Cell

With the style MC_GS_FOCUSEDCELL, the control supports a cell focus. Then, exactly one cell has a status of the focused cell.

Certain aspects of control behavior change when the style is enabled:

Application can set and get currently focused cell with messages MC_GM_SETFOCUSEDCELL and MC_GM_GETFOCUSEDCELL, and be notified about its change of focused cell via the notification MC_GN_FOCUSEDCELLCHANGING and MC_GN_FOCUSEDCELLCHANGED.

Standard Messages

These standard messages are handled by MC_WC_GRID control:

These standard notifications are sent by the control:

Data Structures

struct  MC_GRECT
 A miscellaneous structure determining a rectangular area in the grid. More...
 
struct  MC_GGEOMETRY
 Structure describing inner geometry of the grid. More...
 
struct  MC_GHITTESTINFO
 Structure for message MC_GM_HITTEST. More...
 
struct  MC_GSELECTION
 Structure describing a selection. More...
 
struct  MC_NMGCACHEHINT
 Structure used by notification MC_GN_ODCACHEHINT. More...
 
struct  MC_NMGCUSTOMDRAW
 Structure used by the standard notification NM_CUSTOMDRAW. More...
 
struct  MC_NMGDISPINFOW
 Structure used by notifications MC_GN_GETDISPINFO and MC_GN_SETDISPINFO (Unicode variant). More...
 
struct  MC_NMGDISPINFOA
 Structure used by notifications MC_GN_GETDISPINFO and MC_GN_SETDISPINFO (ANSI variant). More...
 
struct  MC_NMGCOLROWSIZECHANGE
 Structure used by notifications related to resizing of column and headers. More...
 
struct  MC_NMGFOCUSEDCELLCHANGE
 Structure used by notifications related to focused cell. More...
 
struct  MC_NMGSELECTIONCHANGE
 Structure used by notifications related to selection change. More...
 

Initialization Functions

BOOL mcGrid_Initialize (void)
 
void mcGrid_Terminate (void)
 

Window Class

#define MC_WC_GRIDW   L"mCtrl.grid"
 
#define MC_WC_GRIDA   "mCtrl.grid"
 

Control Styles

#define MC_GS_NOTABLECREATE   0x0001
 Do not automatically create empty table. More...
 
#define MC_GS_NOGRIDLINES   0x0002
 Do not paint grid lines. More...
 
#define MC_GS_DOUBLEBUFFER   0x0004
 Use double buffering. More...
 
#define MC_GS_OWNERDATA   0x0008
 Enable the virtual grid mode. More...
 
#define MC_GS_RESIZABLECOLUMNS   0x0010
 Enable changing column width by dragging header divider. More...
 
#define MC_GS_RESIZABLEROWS   0x0020
 Enable changing row height by dragging row header divider. More...
 
#define MC_GS_FOCUSEDCELL   0x0040
 Enables cell focus. More...
 
#define MC_GS_NOSEL   0x0000
 Control does not allow cell selection. More...
 
#define MC_GS_SINGLESEL   0x0100
 Control allows to select only one cell. More...
 
#define MC_GS_RECTSEL   0x0200
 Control allows to select only a rectangular area of cells. More...
 
#define MC_GS_COMPLEXSEL   0x0300
 Control allows to select any arbitrary set of cells. More...
 
#define MC_GS_SHOWSELALWAYS   0x0400
 Paint selection even when the control does not have focus. More...
 
#define MC_GS_COLUMNHEADERNORMAL   0x0000
 The contents of column headers is used. This is default. More...
 
#define MC_GS_COLUMNHEADERNUMBERED   0x1000
 Columns have numerical headers (i.e. "1", "2", "3" etc.) More...
 
#define MC_GS_COLUMNHEADERALPHABETIC   0x2000
 Columns have alphabetical headers (i.e. "A", "B", "C" etc.) More...
 
#define MC_GS_COLUMNHEADERNONE   0x3000
 Columns have no header. More...
 
#define MC_GS_COLUMNHEADERMASK
 Bit mask specifying the column header mode. More...
 
#define MC_GS_ROWHEADERNORMAL   0x0000
 The contents of row headers is used. This is default. More...
 
#define MC_GS_ROWHEADERNUMBERED   0x4000
 Rows have numerical headers (i.e. "1", "2", "3" etc.) More...
 
#define MC_GS_ROWHEADERALPHABETIC   0x8000
 Rows have alphabetical headers (i.e. "A", "B", "C" etc.) More...
 
#define MC_GS_ROWHEADERNONE   0xC000
 Rows have no header. This is default. More...
 
#define MC_GS_ROWHEADERMASK
 Bit mask specifying the row header mode. More...
 

MC_GGEOMETRY::fMask Bits

#define MC_GGF_COLUMNHEADERHEIGHT   (1 << 0)
 Set if MC_GGEOMETRY::wColumnHeaderHeight is valid. More...
 
#define MC_GGF_ROWHEADERWIDTH   (1 << 1)
 Set if MC_GGEOMETRY::wRowHeaderWidth is valid. More...
 
#define MC_GGF_DEFCOLUMNWIDTH   (1 << 2)
 Set if MC_GGEOMETRY::wDefColumnWidth is valid. More...
 
#define MC_GGF_DEFROWHEIGHT   (1 << 3)
 Set if MC_GGEOMETRY::wDefRowHeight is valid. More...
 
#define MC_GGF_PADDINGHORZ   (1 << 4)
 Set if MC_GGEOMETRY::wPaddingHorz is valid. More...
 
#define MC_GGF_PADDINGVERT   (1 << 5)
 Set if MC_GGEOMETRY::wPaddingVert is valid. More...
 

MC_GHITTESTINFO::flags Bits

#define MC_GHT_NOWHERE   (1 << 0)
 In the client area, but does not hit any cell. More...
 
#define MC_GHT_ONCOLUMNHEADER   (1 << 1)
 On a column header cell. More...
 
#define MC_GHT_ONROWHEADER   (1 << 2)
 On a row header cell. More...
 
#define MC_GHT_ONHEADER   (MC_GHT_ONCOLUMNHEADER | MC_GHT_ONROWHEADER)
 On any header cell. More...
 
#define MC_GHT_ONNORMALCELL   (1 << 3)
 On normal cell. More...
 
#define MC_GHT_ONCELL   (MC_GHT_ONHEADER | MC_GHT_ONNORMALCELL)
 On cell. More...
 
#define MC_GHT_ONCOLUMNDIVIDER   (1 << 4)
 Not supported, reserved for future use. More...
 
#define MC_GHT_ONROWDIVIDER   (1 << 5)
 Not supported, reserved for future use. More...
 
#define MC_GHT_ONCOLUMNDIVOPEN   (1 << 6)
 Not supported, reserved for future use. More...
 
#define MC_GHT_ONROWDIVOPEN   (1 << 7)
 Not supported, reserved for future use. More...
 
#define MC_GHT_ABOVE   (1 << 8)
 Above the client area. More...
 
#define MC_GHT_BELOW   (1 << 9)
 Below the client area. More...
 
#define MC_GHT_TORIGHT   (1 << 10)
 To right of the client area. More...
 
#define MC_GHT_TOLEFT   (1 << 11)
 To left of the client area. More...
 

Control Messages

#define MC_GM_GETTABLE   (MC_GM_FIRST + 0)
 Gets handle of table attached to the control or NULL if none is attached. More...
 
#define MC_GM_SETTABLE   (MC_GM_FIRST + 1)
 Attaches a table to the control. More...
 
#define MC_GM_GETCOLUMNCOUNT   (MC_GM_FIRST + 2)
 Gets count of columns in table attached to the control. More...
 
#define MC_GM_GETROWCOUNT   (MC_GM_FIRST + 3)
 Gets count of rows in table attached to the control. More...
 
#define MC_GM_RESIZE   (MC_GM_FIRST + 4)
 Resizes table attached to the control. More...
 
#define MC_GM_CLEAR   (MC_GM_FIRST + 5)
 Clears the table. More...
 
#define MC_GM_SETCELLW   (MC_GM_FIRST + 6)
 Sets a table cell (Unicode variant). More...
 
#define MC_GM_SETCELLA   (MC_GM_FIRST + 7)
 Sets a table cell (ANSI variant). More...
 
#define MC_GM_GETCELLW   (MC_GM_FIRST + 8)
 Gets a table cell (Unicode variant). More...
 
#define MC_GM_GETCELLA   (MC_GM_FIRST + 9)
 Gets a table cell (ANSI variant). More...
 
#define MC_GM_SETGEOMETRY   (MC_GM_FIRST + 10)
 Sets geometry of the grid. More...
 
#define MC_GM_GETGEOMETRY   (MC_GM_FIRST + 11)
 Sets geometry of the grid. More...
 
#define MC_GM_REDRAWCELLS   (MC_GM_FIRST + 12)
 Requests to redraw region of cells. More...
 
#define MC_GM_SETCOLUMNWIDTH   (MC_GM_FIRST + 13)
 Set width of specified column. More...
 
#define MC_GM_GETCOLUMNWIDTH   (MC_GM_FIRST + 14)
 Get width of specified column. More...
 
#define MC_GM_SETROWHEIGHT   (MC_GM_FIRST + 15)
 Set height of specified row. More...
 
#define MC_GM_GETROWHEIGHT   (MC_GM_FIRST + 16)
 Get height of specified row. More...
 
#define MC_GM_HITTEST   (MC_GM_FIRST + 17)
 Tests which cell (and its part) is placed on specified position. More...
 
#define MC_GM_GETCELLRECT   (MC_GM_FIRST + 18)
 Get cell rectangle. More...
 
#define MC_GM_ENSUREVISIBLE   (MC_GM_FIRST + 19)
 Ensure the cell is visible. More...
 
#define MC_GM_SETFOCUSEDCELL   (MC_GM_FIRST + 20)
 Set cell which has focus. More...
 
#define MC_GM_GETFOCUSEDCELL   (MC_GM_FIRST + 21)
 Get cell which has focus. More...
 
#define MC_GM_SETSELECTION   (MC_GM_FIRST + 22)
 Set selection. More...
 
#define MC_GM_GETSELECTION   (MC_GM_FIRST + 23)
 Get selection. More...
 

Control Notifications

#define MC_GN_ODCACHEHINT   (MC_GN_FIRST + 0)
 Notification providing a hint for data caching strategy for grids with virtual table. More...
 
#define MC_GN_GETDISPINFOW   (MC_GN_FIRST + 3)
 Fired when control needs to retrieve some cell data, the parent holds (Unicode variant). More...
 
#define MC_GN_GETDISPINFOA   (MC_GN_FIRST + 4)
 Fired when control needs to retrieve some cell data, the parent holds (ANSI variant). More...
 
#define MC_GN_BEGINCOLUMNTRACK   (MC_GN_FIRST + 5)
 Fired when user has begun dragging a column header divider in the control. More...
 
#define MC_GN_ENDCOLUMNTRACK   (MC_GN_FIRST + 6)
 Fired when user has finished dragging a column header divider in the control. More...
 
#define MC_GN_BEGINROWTRACK   (MC_GN_FIRST + 7)
 Fired when user has begun dragging a row header divider in the control. More...
 
#define MC_GN_ENDROWTRACK   (MC_GN_FIRST + 8)
 Fired when user has finished dragging a row header divider in the control. More...
 
#define MC_GN_COLUMNWIDTHCHANGING   (MC_GN_FIRST + 9)
 Fired when column width is about to change. More...
 
#define MC_GN_COLUMNWIDTHCHANGED   (MC_GN_FIRST + 10)
 Fired after column width has been changed. More...
 
#define MC_GN_ROWHEIGHTCHANGING   (MC_GN_FIRST + 11)
 Fired when column width is about to change. More...
 
#define MC_GN_ROWHEIGHTCHANGED   (MC_GN_FIRST + 12)
 Fired after row height has been changed. More...
 
#define MC_GN_FOCUSEDCELLCHANGING   (MC_GN_FIRST + 13)
 Fired when focused cell is about to change. More...
 
#define MC_GN_FOCUSEDCELLCHANGED   (MC_GN_FIRST + 14)
 Fired after focused cell has been changed. More...
 
#define MC_GN_SELECTIONCHANGING   (MC_GN_FIRST + 15)
 Fired when selection is about to change. More...
 
#define MC_GN_SELECTIONCHANGED   (MC_GN_FIRST + 16)
 Fired after selection has been changed. More...
 

Unicode Resolution

#define MC_WC_GRID   MCTRL_NAME_AW(MC_WC_GRID)
 
#define MC_NMGDISPINFO   MCTRL_NAME_AW(MC_NMGDISPINFO)
 
#define MC_GM_SETCELL   MCTRL_NAME_AW(MC_GM_SETCELL)
 
#define MC_GM_GETCELL   MCTRL_NAME_AW(MC_GM_GETCELL)
 
#define MC_GN_SETDISPINFO   MCTRL_NAME_AW(MC_GN_SETDISPINFO)
 
#define MC_GN_GETDISPINFO   MCTRL_NAME_AW(MC_GN_GETDISPINFO)
 

Data Structure Documentation

struct MC_GRECT

A miscellaneous structure determining a rectangular area in the grid.

Note that by convention the top left corner (wColumnFrom, wRowFrom) is inclusive and the right bottom corner (wColumnTo, wRowTo) is exclusive.

Data Fields
WORD wColumnFrom

The left column coordinate.

WORD wRowFrom

The top row coordinate.

WORD wColumnTo

The right column coordinate.

WORD wRowTo

The bottom row coordinate.

struct MC_GGEOMETRY

Structure describing inner geometry of the grid.

See also
MC_GM_SETGEOMETRY MC_GM_GETGEOMETRY
Data Fields
DWORD fMask

Bitmask specifying which other members are valid. See MC_GGF_xxxx.

WORD wColumnHeaderHeight

Height of column header cells.

WORD wRowHeaderWidth

Width of row header cells.

WORD wDefColumnWidth

Default width of regular contents cells.

WORD wDefRowHeight

Default height of regular contents cells.

WORD wPaddingHorz

Horizontal padding in cells.

WORD wPaddingVert

Vertical padding in cells.

struct MC_GHITTESTINFO

Structure for message MC_GM_HITTEST.

Data Fields
POINT pt

Client coordinate of the point to test.

UINT flags

Flag receiving detail about result of the test. See MC_GHT_xxxx

WORD wColumn

Column index of the cell that occupies the point.

WORD wRow

Row index of the cell that occupies the point.

struct MC_GSELECTION

Structure describing a selection.

In general, the selection is described as a set of rectangular areas. All cells in any of those areas is then considered selected.

The control guarantees that on output (when using MC_GM_GETSELECTION or handling any selection-related notification), the rectangles do not overlap each other.

I.e. the following code snippet can be used to enumerate all the cells within the selection sel:

UINT uIndex;
WORD wCol, wRow;
for(uIndex = 0; uIndex < sel.uDataCount; uIndex++) {
MC_GRECT* pRc = &sel.rcData[uIndex];
for(wRow = pRc->wRowFrom; wRow < pRc->wRowTo; wRow++) {
for(wCol = pRc->wColumnFrom; wCol < pRc->wColumnTo; wCol++) {
// ... process the cell [wCol, wRow]
}
}
}
See also
MC_GM_SETSELECTION MC_GM_GETSELECTION
MC_GN_SELECTIONCHANGING MC_GN_SELECTIONCHANGED
Data Fields
MC_GRECT rcExtents

Extents rectangle of the selection. This member is ignored on input.

UINT uDataCount

Count of rectangles in the rcData array. Zero if no cell is selected. The count may be larger then 1 only if style MC_GS_COMPLEXSEL is used.

MC_GRECT * rcData

Pointer to array (of uCount members) of rectangles describing the selection.

struct MC_NMGCACHEHINT

Structure used by notification MC_GN_ODCACHEHINT.

Data Fields
NMHDR hdr

Common notification structure header.

WORD wColumnFrom

First column of the region to be cached.

WORD wRowFrom

First row of the region to be cached.

WORD wColumnTo

Last column of the region to be cached.

WORD wRowTo

Last row of the region to be cached.

struct MC_NMGCUSTOMDRAW

Structure used by the standard notification NM_CUSTOMDRAW.

Data Fields
MC_NMCUSTOMDRAW nmcd

Standard custom-draw structure. Note that for draw stages related to a cell (item), i.e. when nmcd.dwDrawStage has set the flag CDDS_ITEM, LOWORD(nmcd.dwItemSpec) specifies column index and HIWORD(nmcd.dwItemSpec) specifies row index.

COLORREF clrText

Item text color.

COLORREF clrTextBk

Item background color.

struct MC_NMGDISPINFOW

Structure used by notifications MC_GN_GETDISPINFO and MC_GN_SETDISPINFO (Unicode variant).

Data Fields
NMHDR hdr

Common notification structure header.

WORD wColumn

Column index.

WORD wRow

Row index.

MC_TABLECELLW cell

Structure describing the contents of the cell.

struct MC_NMGDISPINFOA

Structure used by notifications MC_GN_GETDISPINFO and MC_GN_SETDISPINFO (ANSI variant).

Data Fields
NMHDR hdr

Common notification structure header.

WORD wColumn

Column index.

WORD wRow

Row index.

MC_TABLECELLA cell

Structure describing the contents of the cell.

struct MC_NMGCOLROWSIZECHANGE

Structure used by notifications related to resizing of column and headers.

See also
MC_GN_COLUMNWIDTHCHANGING MC_GN_COLUMNWIDTHCHANGED
MC_GN_ROWHEIGHTCHANGING MC_GN_ROWHEIGHTCHANGED
Data Fields
NMHDR hdr

Common notification structure header.

WORD wColumnOrRow

Column index (for MC_GN_COLUMNWIDTHCHANGING and MC_GN_COLUMNWIDTHCHANGED), or row index (for MC_GN_ROWHEIGHTCHANGING and MC_GN_ROWHEIGHTCHANGED).

WORD wWidthOrHeight

Column width (for MC_GN_COLUMNWIDTHCHANGING and MC_GN_COLUMNWIDTHCHANGED), or row height (for MC_GN_ROWHEIGHTCHANGING and MC_GN_ROWHEIGHTCHANGED).

struct MC_NMGFOCUSEDCELLCHANGE

Structure used by notifications related to focused cell.

See also
MC_GN_FOCUSEDCELLCHANGING MC_GN_FOCUSEDCELLCHANGED
Data Fields
NMHDR hdr

Common notification structure header.

WORD wOldColumn

Column of old focused cell.

WORD wOldRow

Row of old focused cell.

WORD wNewColumn

Column of new focused cell.

WORD wNewRow

Row of new focused cell.

struct MC_NMGSELECTIONCHANGE

Structure used by notifications related to selection change.

See also
MC_GN_SELECTIONCHANGING MC_GN_SELECTIONCHANGED
Data Fields
NMHDR hdr

Common notification structure header.

MC_GSELECTION oldSelection

Old selection description.

MC_GSELECTION newSelection

New selection description.

Macro Definition Documentation

#define MC_WC_GRIDW   L"mCtrl.grid"

Window class name (Unicode variant).

#define MC_WC_GRIDA   "mCtrl.grid"

Window class name (ANSI variant).

#define MC_GS_NOTABLECREATE   0x0001

Do not automatically create empty table.

#define MC_GS_NOGRIDLINES   0x0002

Do not paint grid lines.

#define MC_GS_DOUBLEBUFFER   0x0004

Use double buffering.

#define MC_GS_OWNERDATA   0x0008

Enable the virtual grid mode.

See Virtual Grid for more info.

#define MC_GS_RESIZABLECOLUMNS   0x0010

Enable changing column width by dragging header divider.

#define MC_GS_RESIZABLEROWS   0x0020

Enable changing row height by dragging row header divider.

#define MC_GS_FOCUSEDCELL   0x0040

Enables cell focus.

#define MC_GS_NOSEL   0x0000

Control does not allow cell selection.

#define MC_GS_SINGLESEL   0x0100

Control allows to select only one cell.

#define MC_GS_RECTSEL   0x0200

Control allows to select only a rectangular area of cells.

#define MC_GS_COMPLEXSEL   0x0300

Control allows to select any arbitrary set of cells.

#define MC_GS_SHOWSELALWAYS   0x0400

Paint selection even when the control does not have focus.

#define MC_GS_COLUMNHEADERNORMAL   0x0000

The contents of column headers is used. This is default.

#define MC_GS_COLUMNHEADERNUMBERED   0x1000

Columns have numerical headers (i.e. "1", "2", "3" etc.)

#define MC_GS_COLUMNHEADERALPHABETIC   0x2000

Columns have alphabetical headers (i.e. "A", "B", "C" etc.)

#define MC_GS_COLUMNHEADERNONE   0x3000

Columns have no header.

#define MC_GS_COLUMNHEADERMASK
Value:
MC_GS_COLUMNHEADERNUMBERED | \
MC_GS_COLUMNHEADERALPHABETIC | \
MC_GS_COLUMNHEADERNONE)
#define MC_GS_COLUMNHEADERNORMAL
The contents of column headers is used. This is default.
Definition: grid.h:274

Bit mask specifying the column header mode.

#define MC_GS_ROWHEADERNORMAL   0x0000

The contents of row headers is used. This is default.

#define MC_GS_ROWHEADERNUMBERED   0x4000

Rows have numerical headers (i.e. "1", "2", "3" etc.)

#define MC_GS_ROWHEADERALPHABETIC   0x8000

Rows have alphabetical headers (i.e. "A", "B", "C" etc.)

#define MC_GS_ROWHEADERNONE   0xC000

Rows have no header. This is default.

#define MC_GS_ROWHEADERMASK
Value:
MC_GS_ROWHEADERNUMBERED | \
MC_GS_ROWHEADERALPHABETIC | \
MC_GS_ROWHEADERNONE)
#define MC_GS_ROWHEADERNORMAL
The contents of row headers is used. This is default.
Definition: grid.h:288

Bit mask specifying the row header mode.

#define MC_GGF_COLUMNHEADERHEIGHT   (1 << 0)
#define MC_GGF_ROWHEADERWIDTH   (1 << 1)
#define MC_GGF_DEFCOLUMNWIDTH   (1 << 2)
#define MC_GGF_DEFROWHEIGHT   (1 << 3)

Set if MC_GGEOMETRY::wDefRowHeight is valid.

#define MC_GGF_PADDINGHORZ   (1 << 4)

Set if MC_GGEOMETRY::wPaddingHorz is valid.

#define MC_GGF_PADDINGVERT   (1 << 5)

Set if MC_GGEOMETRY::wPaddingVert is valid.

#define MC_GHT_NOWHERE   (1 << 0)

In the client area, but does not hit any cell.

#define MC_GHT_ONCOLUMNHEADER   (1 << 1)

On a column header cell.

#define MC_GHT_ONROWHEADER   (1 << 2)

On a row header cell.

#define MC_GHT_ONHEADER   (MC_GHT_ONCOLUMNHEADER | MC_GHT_ONROWHEADER)

On any header cell.

#define MC_GHT_ONNORMALCELL   (1 << 3)

On normal cell.

#define MC_GHT_ONCELL   (MC_GHT_ONHEADER | MC_GHT_ONNORMALCELL)

On cell.

#define MC_GHT_ONCOLUMNDIVIDER   (1 << 4)

Not supported, reserved for future use.

#define MC_GHT_ONROWDIVIDER   (1 << 5)

Not supported, reserved for future use.

#define MC_GHT_ONCOLUMNDIVOPEN   (1 << 6)

Not supported, reserved for future use.

#define MC_GHT_ONROWDIVOPEN   (1 << 7)

Not supported, reserved for future use.

#define MC_GHT_ABOVE   (1 << 8)

Above the client area.

#define MC_GHT_BELOW   (1 << 9)

Below the client area.

#define MC_GHT_TORIGHT   (1 << 10)

To right of the client area.

#define MC_GHT_TOLEFT   (1 << 11)

To left of the client area.

#define MC_GM_GETTABLE   (MC_GM_FIRST + 0)

Gets handle of table attached to the control or NULL if none is attached.

Note that calling the message does not change reference counter of the returned table. If you want to preserve the handle, you should call mcTable_AddRef() on it and then mcTable_Release() when you no longer need it.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(MC_HTABLE) Handle of the table, or NULL.
#define MC_GM_SETTABLE   (MC_GM_FIRST + 1)

Attaches a table to the control.

Reference counter of the table is incremented. Previously attached table (if any) is detached and its reference counter is decremented.

If the wParam is NULL, the control creates new table (with reference count set to one), unless the control has style MC_GS_NOTABLECREATE.

Parameters
wParamReserved, set to zero.
[in]lParam(MC_HTABLE) Handle of the table, or NULL.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETCOLUMNCOUNT   (MC_GM_FIRST + 2)

Gets count of columns in table attached to the control.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(WORD) Returns count of table columns.
#define MC_GM_GETROWCOUNT   (MC_GM_FIRST + 3)

Gets count of rows in table attached to the control.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(WORD) Returns count of table rows.
#define MC_GM_RESIZE   (MC_GM_FIRST + 4)

Resizes table attached to the control.

Parameters
[in]wParam(DWORD) The low-order word specifies count of columns, high-order word specifies count of rows.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_CLEAR   (MC_GM_FIRST + 5)

Clears the table.

Parameters
[in]wParamSpecification of the cells to be cleared. When set to zero, all table contents (including header cells) is cleared. When non-zero, the value is interpreted as a bit-mask of cells to clear: Set bit 0x1 to clear all ordinary cells, 0x2 to clear column headers and bit 0x4 to clear row cells.
lParamReserved, set to zero.
Returns
Not defined, do not rely on return value.
#define MC_GM_SETCELLW   (MC_GM_FIRST + 6)

Sets a table cell (Unicode variant).

Parameters
[in]wParam(DWORD) Low word specifies column, high word specifies row.
[in]lParam(MC_TABLECELLW*) Pointer to structure describing the cell.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_SETCELLA   (MC_GM_FIRST + 7)

Sets a table cell (ANSI variant).

Parameters
[in]wParam(DWORD) Low word specifies column, high word specifies row.
[in]lParam(MC_TABLECELLA*) Pointer to structure describing the cell.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETCELLW   (MC_GM_FIRST + 8)

Gets a table cell (Unicode variant).

Before calling this function, the member MC_TABLECELL::fMask must specify what attributes of the cell to retrieve.

Parameters
[in]wParam(DWORD) Low word specifies column, high word specifies row.
[out]lParam(MC_TABLECELLW*) Pointer to structure describing the cell.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETCELLA   (MC_GM_FIRST + 9)

Gets a table cell (ANSI variant).

Before calling this function, the member MC_TABLECELL::fMask must specify what attributes of the cell to retrieve.

Parameters
[in]wParam(DWORD) Low word specifies column, high word specifies row.
[out]lParam(MC_TABLECELLA*) Pointer to structure describing the cell.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_SETGEOMETRY   (MC_GM_FIRST + 10)

Sets geometry of the grid.

Parameters
wParamReserved, set to zero.
[in]lParam(MC_GGEOMETRY*) Pointer to structure describing the geometry. Only fields specified by the member fMask are set. If lParam is NULL, the geometry is reset to a default values.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETGEOMETRY   (MC_GM_FIRST + 11)

Sets geometry of the grid.

Parameters
wParamReserved, set to zero.
[in,out]lParam(MC_GGEOMETRY*) Pointer to structure describing the geometry. Only fields specified by the member fMask are retrieved.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_REDRAWCELLS   (MC_GM_FIRST + 12)

Requests to redraw region of cells.

Note the message just invalidates the region of cells, and the control is not actually repainted until it receives a WM_PAINT message.

Parameters
[in]wParamSpecification of top left cell in the region to be (re)painted. Low word specifies its column, high word specifies its row.
[in]lParamSpecification of bottom right cell in the region to be (re)painted. Low word specifies its column, high word specifies its row.
Returns
(BOOL) TRUE on success, FALSE on failure.

For example, to repaint a single cell, use can use code similar to this:

1 SendMessage(hwndGrid, MC_GM_REDRAWCELLS, MAKEWPARAM(wCol, wRow), MAKELPARAM(wCol, wRow));
#define MC_GM_SETCOLUMNWIDTH   (MC_GM_FIRST + 13)

Set width of specified column.

To reset width of the column to the default value (as specified with MC_GGEOMETRY::wDefColumnWidth), set the column width to 0xFFFF.

Note this message can set only width of an ordinary grid column. To change the width of row headers, use MC_GM_SETGEOMETRY.

Parameters
[in]wParam(WORD) Index of the column.
[in]lParam(DWORD) Set low word to the desired width in pixels, high word to zero.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETCOLUMNWIDTH   (MC_GM_FIRST + 14)

Get width of specified column.

Parameters
[in]wParam(WORD) Index of the column.
lParamReserved, set to zero.
Returns
(LRESULT) If the message fails, the return value is -1. On success, low word is the width in pixels, high word is reserved for future and it is currently always set to zero.
#define MC_GM_SETROWHEIGHT   (MC_GM_FIRST + 15)

Set height of specified row.

To reset height of the row to the default value (as specified with MC_GGEOMETRY::wDefRowHeight), set the row height to 0xFFFF.

Note this message can set only height of an ordinary grid row. To change the height of column headers, use MC_GM_SETGEOMETRY.

Parameters
[in]wParam(WORD) Index of the row.
[in]lParam(DWORD) Set low word to the desired height in pixels, high word to zero.
Returns
(BOOL) TRUE on success, FALSE on failure.
#define MC_GM_GETROWHEIGHT   (MC_GM_FIRST + 16)

Get height of specified row.

Parameters
[in]wParam(WORD) Index of the row.
lParamReserved, set to zero.
Returns
(LRESULT) If the message fails, the return value is -1. On success, low word is the height in pixels, high word is reserved for future and it is currently always set to zero.
#define MC_GM_HITTEST   (MC_GM_FIRST + 17)

Tests which cell (and its part) is placed on specified position.

Parameters
wParamReserved, set to zero.
[in,out]lParam(MC_GHITTESTINFO*) Pointer to a hit test structure. Set MC_GHITTESTINFO::pt on input.
Returns
(DWORD) Cell column and row specification, if any, or -1 otherwise. If not -1, in low word of the value, the column index is specified and, in high word of the value, its row index is specified.
#define MC_GM_GETCELLRECT   (MC_GM_FIRST + 18)

Get cell rectangle.

Parameters
[in]wParam(DWORD) Column and row of the cell. Low word specifies column index and high word specifies row index.
[out]lParam(RECT*) Pointer to rectangle.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_GM_ENSUREVISIBLE   (MC_GM_FIRST + 19)

Ensure the cell is visible.

If not visible, the control scrolls to make the cell visible.

Parameters
[in]wParam(DWORD) Column and row of the cell. Low word specifies column index and high word specifies row index.
[in]lParam(BOOL) A value specifying whether entire cell should be visible. If TRUE, no scrolling happens when the cell is at least partially visible.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_GM_SETFOCUSEDCELL   (MC_GM_FIRST + 20)

Set cell which has focus.

Parameters
[in]wParam(DWORD) Low word specifies column, high word specifies row. Note that cursor can move only to ordinary cells.
lParamReserved, set to zero.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_GM_GETFOCUSEDCELL   (MC_GM_FIRST + 21)

Get cell which has focus.

Parameters
wParamReserved, set to zero.
lParamReserved, set to zero.
Returns
(DWORD) Low word specifies column, high word specifies row.
#define MC_GM_SETSELECTION   (MC_GM_FIRST + 22)

Set selection.

Parameters
wParamReserved, set to zero.
[in]lParam(MC_GSELECTION*) Pointer to structure describing the selection, or NULL to reset selection.
Returns
(BOOL) TRUE on success, FALSE otherwise.
#define MC_GM_GETSELECTION   (MC_GM_FIRST + 23)

Get selection.

When sending this message application has set some members of MC_GSELECTION, as provided via lParam. There are three modes operations.

  • Application sets lParam to NULL. Then no actual data are retrieved and the message only returns the count of rectangles the selection is composed of.
  • Application provides a buffer where control fills the selection data. The application has to set MC_GSELECTION::rcData to point to the buffer, and MC_GSELECTION::uDataCount to maximal count of rectangles the buffer can hold. On output, the MC_GSELECTION::uDataCount is set to the actual count of rectangles copied into the buffer.
  • Application does not provide any buffer. In this case the application has to set MC_GSELECTION::uDataCount to (UINT)-1. Instead of copying, the control sets MC_GSELECTION::rcData to point into its internal buffer. In this mode application must not free or modify the contents of the internal buffer, and also it must not retain the pointer for later use as it may become invalid any time.
Parameters
wParamReserved, set to zero.
[in,out]lParam(MC_GSELECTION*) Pointer to structure to be filled by the control, or NULL. Application has initialize some members of the structure as described above.
Returns
(UINT) Count of rectangles required for MC_GSELECTION::rcData on success. Zero means the selection is empty.
#define MC_GN_ODCACHEHINT   (MC_GN_FIRST + 0)

Notification providing a hint for data caching strategy for grids with virtual table.

The notification is sent only when the control has the style MC_GS_OWNERDATA. The notification informs the application about region of cells it is likely to ask for (via MC_GN_GETDISPINFO).

If the retrieval of assorted data by the application is slow (e.g. because it requires remote access to a database system), the application should cache locally the data for cells in the rectangular cell region as specified by the MC_NMGCACHEHINT.

The structure never specify header cells, however if the control has style MC_GS_COLUMNHEADERNORMAL and/or MC_GS_ROWHEADERNORMAL, it should also cache data needed for column/row headers corresponding for the cells in the region.

For example, if the grid uses the styles MC_GS_COLUMNHEADERNORMAL and MC_GS_ROWHEADERNORMAL, the following data are recommended to be cached within the application:

  • All ordinary cells in the rectangle with left top cell [columnFrom, rowFrom] and right bottom cell [columnTo, rowTo].
  • All column header cells in the range columnFrom ... columnFrom.
  • All row header cells in the range rowFrom ... rowTo.

In general, the specified cell region roughly corresponds to cells currently visible in the control's window client area.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCACHEHINT*) Pointer to MC_NMGCACHEHINT structure.
Returns
None.
#define MC_GN_GETDISPINFOW   (MC_GN_FIRST + 3)

Fired when control needs to retrieve some cell data, the parent holds (Unicode variant).

This may happen when MC_TABLECELL::pszText was set to the magical value MC_LPSTR_TEXTCALLBACK, or when the control has the style MC_GS_OWNERDATA.

When sending the notification, the control sets MC_NMGDISPINFO::wColumn and MC_NMGDISPINFO::wRow to identify the cell. The control also sets MC_NMTLDISPINFO::item::lParam (however if the style MC_GS_OWNERDATA is in effect, it is always set to zero).

The control specifies what members in MC_NMGDISPINFO::cell the application should fill with the MC_NMGDISPINFO::cell::fMask. Note that the mask can ask for both, the cell text as well the value. However application is then expected to provide one or the other (and set the other one to NULL).

Parameters
[in]wParam(int) Id of the control sending the notification.
[in,out]lParam(MC_NMGDISPINFO*) Pointer to MC_NMGDISPINFO structure.
Returns
None.
#define MC_GN_GETDISPINFOA   (MC_GN_FIRST + 4)

Fired when control needs to retrieve some cell data, the parent holds (ANSI variant).

This may happen when MC_TABLECELL::pszText was set to the magical value MC_LPSTR_TEXTCALLBACK, or when the control has the style MC_GS_OWNERDATA.

When sending the notification, the control sets MC_NMGDISPINFO::wColumn and MC_NMGDISPINFO::wRow to identify the cell. The control also sets MC_NMTLDISPINFO::item::lParam (however if the style MC_GS_OWNERDATA is in effect, it is always set to zero).

The control specifies what members in MC_NMGDISPINFO::cell the application should fill with the MC_NMGDISPINFO::cell::fMask. Note that the mask can ask for both, the cell text as well the value. However application is then expected to provide one or the other (and set the other one to NULL).

Parameters
[in]wParam(int) Id of the control sending the notification.
[in,out]lParam(MC_NMGDISPINFO*) Pointer to MC_NMGDISPINFO structure.
Returns
None.
#define MC_GN_BEGINCOLUMNTRACK   (MC_GN_FIRST + 5)

Fired when user has begun dragging a column header divider in the control.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
TRUE to prevent the column width change, FALSE to allow it.
#define MC_GN_ENDCOLUMNTRACK   (MC_GN_FIRST + 6)

Fired when user has finished dragging a column header divider in the control.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_GN_BEGINROWTRACK   (MC_GN_FIRST + 7)

Fired when user has begun dragging a row header divider in the control.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
TRUE to prevent the row height change, FALSE to allow it.
#define MC_GN_ENDROWTRACK   (MC_GN_FIRST + 8)

Fired when user has finished dragging a row header divider in the control.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_GN_COLUMNWIDTHCHANGING   (MC_GN_FIRST + 9)

Fired when column width is about to change.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
TRUE to prevent the column width change, FALSE to allow it.
#define MC_GN_COLUMNWIDTHCHANGED   (MC_GN_FIRST + 10)

Fired after column width has been changed.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_GN_ROWHEIGHTCHANGING   (MC_GN_FIRST + 11)

Fired when column width is about to change.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
TRUE to prevent the row height change, FALSE to allow it.
#define MC_GN_ROWHEIGHTCHANGED   (MC_GN_FIRST + 12)

Fired after row height has been changed.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGCOLROWSIZECHANGE*) Pointer to MC_NMGCOLROWSIZECHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_GN_FOCUSEDCELLCHANGING   (MC_GN_FIRST + 13)

Fired when focused cell is about to change.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGFOCUSEDCELLCHANGE*) Pointer to MC_NMGFOCUSEDCELLCHANGE structure.
Returns
TRUE to prevent the row height change, FALSE to allow it.
#define MC_GN_FOCUSEDCELLCHANGED   (MC_GN_FIRST + 14)

Fired after focused cell has been changed.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGFOCUSEDCELLCHANGE*) Pointer to MC_NMGFOCUSEDCELLCHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_GN_SELECTIONCHANGING   (MC_GN_FIRST + 15)

Fired when selection is about to change.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGSELECTIONCHANGE*) Pointer to MC_NMGSELECTIONCHANGE structure.
Returns
TRUE to prevent the selection change, FALSE to allow it.
#define MC_GN_SELECTIONCHANGED   (MC_GN_FIRST + 16)

Fired after selection has been changed.

Parameters
[in]wParam(int) Id of the control sending the notification.
[in]lParam(MC_NMGSELECTIONCHANGE*) Pointer to MC_NMGSELECTIONCHANGE structure.
Returns
Application should return zero if it processes the notification.
#define MC_WC_GRID   MCTRL_NAME_AW(MC_WC_GRID)

Unicode-resolution alias.

See also
MC_WC_GRIDW MC_WC_GRIDA
#define MC_NMGDISPINFO   MCTRL_NAME_AW(MC_NMGDISPINFO)

Unicode-resolution alias.

See also
MC_NMGDISPINFOW MC_NMGDISPINFOA
#define MC_GM_SETCELL   MCTRL_NAME_AW(MC_GM_SETCELL)

Unicode-resolution alias.

See also
MC_GM_SETCELLW MC_GM_SETCELLA
#define MC_GM_GETCELL   MCTRL_NAME_AW(MC_GM_GETCELL)

Unicode-resolution alias.

See also
MC_GM_GETCELLW MC_GM_GETCELLA
#define MC_GN_SETDISPINFO   MCTRL_NAME_AW(MC_GN_SETDISPINFO)

Unicode-resolution alias.

See also
MC_GN_SETDISPINFOW MC_GN_SETDISPINFOA
#define MC_GN_GETDISPINFO   MCTRL_NAME_AW(MC_GN_GETDISPINFO)

Unicode-resolution alias.

See also
MC_GN_GETDISPINFOW MC_GN_GETDISPINFOA

Function Documentation

BOOL mcGrid_Initialize ( void  )

Registers window class of the control.

Returns
TRUE on success, FALSE on failure.
void mcGrid_Terminate ( void  )

Unregisters window class of the control.