<< Return to Main Index

< Return to Class Index

CGXGridCore::GetArrayWithColWidths

void GetArrayWithColWidths(ROWCOL nFromCol, ROWCOL nToCol, int* pnColWidths);

nFromCol

Specifies the first column id.

nToCol

Specifies the last column id.

pnColWidths

A pointer to the result array.

Remarks

Fills the array with the specified column-widths. You are responsible for allocating and destroying the array after usage.

Example

This example shows the usage of GetArrayWithColWidths. First, an array with column-widths is created. Next, this array is used as information containing the old column-widths. After usage it is destroyed.

BOOL CGXGridCore::SetColWidth(ROWCOL nFromCol, ROWCOL nToCol, int nWidth, int* anWidthArray, UINT flags, GXCmdType ctCmd)
{
   ASSERT(anWidthArray == NULL || nWidth == 0);
   // ASSERTION-> Ambiguous command call ->END

   CGXLongOperation theOp;

   if (nToCol == 0)
      nToCol = nFromCol;

   ASSERT(nToCol >= nFromCol);

   CGXCommand* pCmdUndo = NULL;

   if (nToCol == 0 || m_pParam->IsEnableTrackColWidth(GX_INDIVIDUAL))
   {
      int* pnOldWidths = new int[nToCol-nFromCol+1];
      GetArrayWithColWidths(nFromCol, nToCol, pnOldWidths);
      BOOL b = FALSE;
      for (ROWCOL nCol = nFromCol; nCol <= nToCol; nCol++)
      {
         if (anWidthArray)
            b |= StoreColWidth(nCol, anWidthArray[nCol-nFromCol]);
         else
            b |= StoreColWidth(nCol, nWidth);

         theOp.DoMessages( );
      }
      if (b)
      {
         UpdateChangedColWidths(nFromCol, nToCol, pnOldWidths, flags, TRUE);

         if (ctCmd != gxRollback && m_pParam->m_bUndoEnabled)
         {
            AddCommand(new CGXSetColWidthCmd(nFromCol, nToCol, pnOldWidths), ctCmd);   // CGXSetColWidthCmd will delete nOldWidths
            if (ctCmd == gxRedo || ctCmd == gxUndo)
               OnCellUndone(GetTopRow( ), nFromCol);
         }
         else
            delete pnOldWidths;
         return TRUE;
      }
   }
   else
      return SetDefaultColWidth(nWidth, flags);
   return FALSE;
}

See Also

CGXGridCore::GetColWidth

CGXGridCore

Class Overview | Class Members