class CGXStatic: public CGXControl

The CGXStatic class implements a static text control which can be used to display text in cells. The user cannot modify this text in place, but can change any style attributes with the CGXStyleSheet dialog.

Style attributes that specify the appearance of the cell are:

·Text with SetValue.
·Text color with SetColor.
·Background color with SetInterior.
·Cell frame 3d-effect (raised, inset, normal) with SetDraw3dFrame.
·Borders with SetBorder.
·Horizontal alignment with SetHorizontalAlignment
·Vertical alignment with SetVerticalAlignment
·Font with SetFont
·Wordbreak with SetWrapText

CGXStatic supports finding text in cells.

The default id for CGXStatic controls is GX_IDS_CTRL_STATIC

You can apply static text to cells with

   SetStyleRange(range,
      CGXStyle()
         .SetControl(GX_IDS_CTRL_STATIC)
         .SetValue("Static Text")
      );

CGXStatic supports displaying bitmaps in cells. Bitmaps can be expressed through the value string in a cell. The alignment of bitmaps can be specified with SetHorizontalAlignment and SetVerticalAlignment.

Examples for using bitmaps are:

   SetStyleRange(CGXRange(18, 1),
        CGXStyle()
           .SetControl(GX_IDS_CTRL_STATIC)
           .SetValue("#BMP(121)")
           .SetHorizontalAlignment(DT_CENTER)
           .SetVerticalAlignment(DT_VCENTER)
        );
     SetStyleRange(CGXRange(18, 2),
        CGXStyle()
           .SetControl(GX_IDS_CTRL_STATIC)
           .SetValue("#BMP(127)")
           .SetHorizontalAlignment(DT_CENTER)
           .SetVerticalAlignment(DT_VCENTER)
        );

whereas 127 and 121 (the value in parenthesis) is the resource id of the bitmap to be displayed in the cell.

You can also use bitmaps in headers:

   // Display bitmap in row header
     SetStyleRange(CGXRange(18, 0),
        CGXStyle()
           .SetValue("#BMP(127)")
           .SetHorizontalAlignment(DT_CENTER)
           .SetVerticalAlignment(DT_VCENTER)
        );
// or display bitmap in column header
     SetStyleRange(CGXRange(0, 5),
        CGXStyle()
           .SetValue("#BMP(128)")
           .SetHorizontalAlignment(DT_CENTER)
           .SetVerticalAlignment(DT_VCENTER)
        );

You can assign bitmaps to cells depending of the context of the grid when you override GetStyleRowCol and call style.SetValue(...);

If you don't like using a numeric resource id, you can also use names.

For example, if a bitmap is declared in your resource file as

YES BITMAP DISCARDABLE "RES\\YES12.BMP"

(and YES is not a integer id defined in resource.h), you can assign this bitmap to cells with

   SetStyleRange(CGXRange(18, 1),
        CGXStyle()
           .SetControl(GX_IDS_CTRL_STATIC)
           .SetValue("#BMP(\"YES\")")
           .SetHorizontalAlignment(DT_CENTER)
           .SetVerticalAlignment(DT_VCENTER)
        );

NOTE:

Static cells can be manipulated by the end user, e.g. the user can delete the cell or paste text into the cell. If you want to protect the cell from beeing modified by the end-user you should make the cell readonly. See CGXStyle::SetReadOnly().

#include <gxall.h>

See Also

 CGXGridCore::RegisterControl  CGXStyle::SetControl  CGXStyle  CGXStyle::SetReadOnly

CGXStatic

 Class Members