MTable

From Team Developer SqlWindows Wiki
Revision as of 21:08, 11 September 2008 by DaveRabelink (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page covers MTable tips & tricks.

Contents


Pointer.pngHow to remove the checkbox from a cell

TableCellHideCheckbox.png

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 )


Pointer.pngEnter new tip title here

Enter new tip description here