CGXStylesMap::AddUserAttribute

void AddUserAttribute(WORD nID, const CGXStyle& style);

void AddUserAttribute(WORD nID, const CGXStyle* pStyle = NULL);

nID

A string resource id where the string resource contains the base style name.

style

A reference to a style object. This style object will be used in the CGXStyleSheet which has “User Page” with a grid of user attributes. The style object specifies the formatting of the cell for this attribute (display a spin control for example.)

pStyle

Pointer to a style object.

Remarks

Call this method to register a user-defined attribute for CGXStyle objects.

To register user-defined attributes, the following steps are necessary:

1.Create a string resource, e.g., GX_IDS_UA_VALID_MIN.

2.Call AddUserAttribute with GX_IDS_UA_VALID_MIN and a style. This style is used for displaying the attribute’s value in the “User-defined attributes” grid in the CGXStyleSheet dialog. Each user-defined attribute is displayed as a row with the name and the attribute’s value. The end-user can change the attribute’s value at run time, where the style defines the appearance of the value (a combo box, a spin control, a specific color or other style settings). For example, the “Valid: Minimum Value”-attribute is defined as follows:

      CGXStyle styleSpin;
      styleSpin.SetControl(GX_IDS_CTRL_SPINEDIT).SetWrapText(FALSE);
         // Validation: Minimum value
      stylesmap->AddUserAttribute(GX_IDS_UA_VALID_MIN,
         &styleSpin);

This means that the end user can click on the spin buttons to increase or decrease the attribute’s value in the CGXStyleSheet.

Note: This method registers user attributes only to appear in the CGXStyleSheet. If you don’t want a user attribute to be visible in the CGXStyleSheet, you don’t have to register it here. You will still be able to use the user attribute with CGXStyle::SetUserAttribute in your grid. You only disable the possibility that the user can change the user attribute through the style sheet.

See Also

 CGXStyle::SetUserAttribute

CGXStylesMap

 Class Overview |  Class Members