<< Return to Main Index

< Return to Class Index

CGXStyleSheet::CGXStyleSheet

CGXStyleSheet(UINT nIDCaption, CGXStylesMap& stylesMap, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);

CGXStyleSheet(LPCTSTR pszCaption, CGXStylesMap& stylesMap, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);

nIDCaption

Specifies a resource id for the text to be displayed in the dialog title.

stylesMap

Reference to the styles-map object.

pParentWnd

Pointer to a parent window. Can be NULL.

iSelectPage

Specifies which page should be activated.

pszCaption

Points to the text to be displayed in the dialog title.

Remarks

Constructs a CGXStyleSheet object.

You can copy the example to your class if you want to provide the dialog for the end user to modify cell styles.

Example

This example shows how to display the dialog if you want the end user to be able to modify cell styles:

void CMyGridView::OnFormatCells()
{
   // if there are no cells selected,
   // copy the current cell's coordinates
   CGXRangeList selList;
   if (!CopyRangeList(selList, TRUE))
      return;

   ROWCOL nRow = selList.GetHead()->top;
   ROWCOL nCol = selList.GetHead()->left;

   CGXStyle style;
   ComposeStyleRowCol(max(nRow, 1), max(nCol, 1), &style);

   CGXStyleSheet sheet("Cells", *GetParam()->GetStylesMap());

   sheet.CreatePages();
   sheet.SetDefaultStyle(style);
   sheet.SetStyle(CGXStyle());

   if (sheet.DoModal() != IDOK)
      return;

   CGXLongOperation theOp;

   BeginTrans(GXGetAppData()->strmCellFormatting);

   TRY
   {
      // selected cells
      POSITION pos = selList.GetHeadPosition();
      while (pos)
      {
         CGXRange rect = selList.GetNext(pos);

         if (!SetStyleRange(rect, sheet.GetStyle(), gxOverride, rect.IsCells() ? 0 : -1))
            AfxThrowUserException();
      }

      CommitTrans();
   }
   CATCH(CUserException, e)
   {
      Rollback();
   }
   END_CATCH
}

See Also

CGXStylesMap CGXStyle

CGXStyleSheet

Class Overview | Class Members