Extended selections

With M!Table you can modify the appearance of selections and/or get a notification when the row/column selection has changed.
Furthermore, you can suppress row selection.

Functions
MTblSetSelectionColors
MTblGetSelectionColors

MTblGetColSelChanges
MTblGetRowSelChanges

MTblEnableExtMsgs

Messages
MTM_ColSelChanged
MTM_RowSelChanged

Table Flags
MTBL_FLAG_FULL_OVERLAP_SELECTION
MTBL_FLAG_SUPPRESS_ROW_SELECTION

Column Flags
MTBL_COL_FLAG_NOINVSEL_IMAGE
MTBL_COL_FLAG_NOINVSEL_TEXT
MTBL_COL_FLAG_NOINVSEL_BKGND

Row Flags
MTBL_ROW_NOSELINV_IMAGE
MTBL_ROW_NOSELINV_TEXT
MTBL_ROW_NOSELINV_BKGND

Cell Flags
MTBL_CELL_FLAG_NOINVSEL_IMAGE
MTBL_CELL_FLAG_NOINVSEL_TEXT
MTBL_CELL_FLAG_NOINVSEL_BKGND

Tree Flags
MTBL_TREE_FLAG_NOSELINV_NODES
MTBL_TREE_FLAG_NOSELINV_LINES


Hints and tips

General
In order to provide these features, M!Table must do the following:

  • Trap selection changes

It's quite difficult to trap the selection changes because there are no explicit messages which indicate this. Therefore, on particular events M!Table has to make a "before image" and "after image" of the row and column selection, e.g. on WM_LBUTTONDOWN or WM_KEYDOWN. Then it must compare the before and after image to see what's different. If there are many selected rows and/or columns in the table, this may take some time.

The selection changes are trapped when one or more of the following is true:

- The generation of extended messages is enabled
- Selection colors are defined
- Any flag regarding selections is set

  • Repaint the areas affected by selection changes

Unfortunately the table window isn't designed very well regarding selections. If you select and/or deselect a row or column, the table window simply inverts the affected area instead of invalidate it, which would generate a WM_PAINT message. There is no way to avoid this, so M!Table must repaint the affected areas after the table window has done it's silly inverting. This may produce some flickering, in particular when many selections changed.
In some cases M!Table uses the API function LockWindowUpdate to avoid that the affected area gets inverted, e.g.:
LockWindowUpdate( hWndTbl ); // Disables drawing in the table
CallOriginalWindowProc( ); // Here your application receives messages
LockWindowUpdate( NULL ); // Enables drawing in the table and redraws it

Be aware of this. The original window procedure may send SAM ( and WM ) messages. Thus, when the application receives the message, the window update is locked! The affected areas are repainted when one or more of the following is true: - Selection colors are defined - Any flag regarding selections is set

Selection colors
Normally, selections are displayed by inverting the selected item, e.g. when a row is selected, the rectangle of the row is inverted.
If you use selection colors, the selected items are not inverted but drawn using the selection instaed of the original colors:

No selection colors defined. This is what we know.

Only background selection color (blue) defined.

Only text selection color (white) defined.

Background selection color (blue) and text selection color (white) defined.

Full overlapping selections
If you set the table flag MTBL_FLAG_FULL_OVERLAP_SELECTION, the cells in the overlapping areas of row and column selection are also inverted or, if selection colors are used, drawn with the selection colors. Let's see the difference:

Flag not set, no selection colors

Flag set, no selection colors

Flag not set, selection colors used

Flag set, selection colors used

The MTBL_*NOSELINV_* flags
With these flags you can avoid that particular items, e.g. images or texts, get inverted on selection, e.g when you set the column flag MTBL_COL_FLAG_NOINVSEL_IMAGE, the images of the column's selected cells aren't inverted:

Flag not set

Flag set

When selection colors are used, these flags have no effect because selections are not inverted then.

The MTM_*Sel_Changed messages
These messages are sent only if the generation of extended messages was enabled with MTblEnableExtMsgs.
To get the changes, call one of the MTblGet*SelChanges functions, e.g. to get the column selection changes:
On MTM_ColSelChanged
 Set nColsChanged = MTblGetColSelChanges( hWndForm, naRows, baChanges )

Please note that a selection change message is sent only when at least one item still exists. Let's say you have a table with some selected rows and call SalTblReset. M!Table doesn't send MTM_RowSelChanged because the rows don't exist anymore.

Created with the Personal Edition of HelpNDoc: Free CHM Help documentation generator