MTable
From TeamDeveloperWiki
This page covers MTable tips & tricks.
Contents |
MTable information and download
For information on MTable, go the the official MTable webpage:
Micsto homepage
There you will find the online documentation and download link.
You can also download it (several versions) from the Sample Vault:
MTable downloads
How to remove the checkbox from a cell
This tip applies to MTable versions prior to 1.9.5.
Starting from MTable 1.9.5, you can hide checkbox cells using:
Flag MTBL_CELL_FLAG_HIDDEN_TEXT
(See MTable documentation for that version).
When you have a checkbox-style column and want to be able to show or hide the checkbox
for certain cells (see screenshot above), this solution can be used :
Owner-draw the cell for which the checkbox should be removed. It is not actually removed, but visually overpainted
so it seems the checkbox is removed.
Follow these steps :
- Disable the cell by using this function : MTblDisableCell
- Set the cell to be owner-drawn using MTblSetOwnerDrawnItem
- Define the message On MTM_DrawItem under Message Actions of the Table
- Call a function in the message to overpaint the cell using the background color of the table.
- See MTable help for info on the function mentioned
Below a sample. Three rows are inserted into the table (column type is checkbox), the second row will be visually hidden.
(See screenshot for the result of this sample).
Child Table: tblCheck
Contents
Column: colCheck
Functions
Function: DrawEmptyCell
Parameters
Number: pnOwnerdrawnItemID
Local variables
fcMTblODI: odi
Number: nBrush
Number: nOldBrush
Actions
If MTblGetOwnerDrawnItem( hWndForm, pnOwnerdrawnItemID, odi )
If odi.Type = MTBL_ODI_CELL
Set nBrush = CreateSolidBrush( SalColorGet( hWndForm, COLOR_IndexWindow ) )
Set nOldBrush = SelectObject( odi.DC, nBrush )
Call FillRect( odi.DC, odi.Left, odi.Top, odi.Right, odi.Bottom, nBrush )
Call SelectObject( odi.DC, nOldBrush )
Call DeleteObject( nBrush )
Function: PopulateTable
Local variables
Number: nRow
Actions
Call SalTblReset( hWndForm )
Set nRow = SalTblInsertRow( hWndForm, TBL_MaxRow )
If nRow > -1
Call SalTblSetContext( hWndForm, nRow )
Set colCheck = "1"
Set nRow = SalTblInsertRow( hWndForm, TBL_MaxRow )
If nRow > -1
Call MTblDisableCell( colCheck, nRow, TRUE )
Call MTblSetOwnerDrawnItem( colCheck, nRow, MTBL_ODI_CELL, TRUE )
Set nRow = SalTblInsertRow( hWndForm, TBL_MaxRow )
If nRow > -1
Call SalTblSetContext( hWndForm, nRow )
Set colCheck = "1"
Message Actions
On SAM_Create
Call MTblSubClass( hWndForm )
Call PopulateTable( )
On MTM_DrawItem
Call DrawEmptyCell( lParam )


