CGXCurrencyEdit::AddUserAttributes

AddUserAttributes(CGXStylesMap* pStylesMap);

pStylesMap

Pointer to the stylesmap

Remarks

Call this static method to register user attributes with the styles-map. Registered user attributes will be displayed in the CGXStyleSheet and can be modified by the user with the style sheet.

If you don't want the attributes to be visible in the CGXStyleSheet, you should not call AddUserAttributes. You will still be able to use user attributes in your grid. They will only be hidden from the user in the CGXStyleSheet.

CGXCurrencyEdit user attributes specify the behavior of the currency control. These need to be specified for the control to be able to display itself in the required format.

CGXCurrencyEdit uses the following user attributes:

  • GX_IDS_UA_CURRENCYDEF: Defines several attributes that cannot be more than single digit values as a single string.

  • format class defines several (seven) attributes of the CGXCurrencyEdit class. This user attribute packs four attributes of the currency control format class as one string. (There is a description of the format class towards the end of the document).

For example CString strCurDef(_T("11 1")) would be interpreted by the control as shown below.

This string would be seen by the control as seven characters each with a value that can be interpreted seperately based on it‘s position in the string.

·char 0 (position 0 in the string) sets EnableLeadingZero for the control. 0 for FALSE and 1 for TRUE

The control would then set the format as below. This would determine whether the control would display leading zero‘s or not.

format.EnableLeadingZero(_ttoi(&c));

In this case strCurDef[0] = 1, Hence the value is TRUE

The other attributes as listed below and will be interpreted in a similar manner.

·char 1 EnableDecimalSeparatorLine 0 for FALSE and 1 for TRUE


   // The control would set it as
   // format.EnableDecimalSeparatorLine(_ttoi(&c));

·char 2 Padding character (Please refer Format reference)

   // The control will set it as format.SetPaddingCharacter(str1[5]);

·char 3 Important attribute:

Specify this attribute if you need the popup calculator!


// The control would interpret this value as below
      c = str1[3];
       For the popup calculator
       if (_ttoi(&c))
         pEdit->SetBitmap(IDB_CALC); // Set bitmap with a valid
         //bitmap lets the control display the calculator.

and the calculator will be shown. (You do not have to specify the bitmap.) All you have to do is to set the last character in the currency def string to 1.

Typical currency def string

CString strCurDef(_T("11 1"));

  • GX_IDS_UA_CURMON: Defines a custom monetary symbol that will be used. If this attribute is not defined then the symbol from the win.ini settings will be used. If you do not want a currency symbol then specify '0' for this attribute.  Specifying a NULL ('\0') will not work. You can customize the default blank-specifier by modifying the static member CGXCurrencyEdit::m_cBlankMonetarySym. By default, m_cBlankMonetarySym is set to '0'.
  • GX_IDS_UA_CURSEP: Defines custom thousand and decimal seperators that will be used. If not specifies defaults from win.ini will be used.  If you do not want a thosands separator then specify '0' for this attribute.  Specifying a NULL ('\0') will not work.  You can customize the default blank-specifier by modifying the static member CGXCurrencyEdit::m_cBlankThouSym.  By default, m_cBlankThouSym is set to '0'.

·char 0 Thousands seperator (Please refer Format reference)

// The control will set it as format.SetThousandSeparator(strSep[0]);

·char 1 Decimal seperator (Please refer Format reference)

// The control will set it as format.SetDecimalSeparator(strSep[1]);
  • ·GX_IDS_UA_CURPOSFORMAT and GX_IDS_UA_CURNEGFORMAT

These user attributes are used to specify the format with which positive and negative numbers will be displayed in the control.

Possible formats are:

Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883 Negative Format Positive Format Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883
Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883 0 ($1) 0 $1 Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883
1 -$1 1 1$ Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883
2 $-1 2 $ 1 Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883
3 $1- 3 1 $ Width1Width3Width1519 Width3Width831 Width3Width1307 Width3Width827 Width3Width883
Width1Width3Width1519 Width3Width831 Width3Width3017 4 (1$) These formats are taken directly from Microsoft's documentation regarding the international section of WIN.INI. The CGXBCurrencyEdit uses them for the positive and negative formats given via the formatting object.Width1Width3Width1519 Width3Width831 Width3Width3017
Width1Width3Width1519 Width3Width831 5 -1$ Width1Width3Width1519 Width3Width831
6 1-$ Width1Width3Width1519 Width3Width831
7 1$- Width1Width3Width1519 Width3Width831
8 -1 $ Width1Width3Width1519 Width3Width831
9 -$ 1 Width1Width3Width1519 Width3Width831
Width1Width3Width1519 Width3Width831 10 $ 1- Width1Width3Width1519 Width3Width831

   // Here is how this value will be used to set the format
      format.SetPositiveFormat(_ttoi(pStyle
         ->GetUserAttribute(GX_IDS_UA_CURPOSFORMAT)));
      format.SetNegativeFormat(_ttoi(pStyle
         ->GetUserAttribute(GX_IDS_UA_CURNEGFORMAT)));
   

The interpretation of these formats is very simple. For example if we have to denote a value of $50 with the format 1$ it will be displayed as 50$. Similarly, negative values with format ($1) will be displayed as ($50) when displayed in the currency control.


                                            
  • GX_IDS_UA_CURNUMDECIMALS: This user attribute specifies the number of whole numbers that will be allowed to the left of the decimal point.
   format.SetDecimalDigits(_ttoi(pStyle
   ->GetUserAttribute(GX_IDS_UA_CURNUMDECIMALS)));
   
  • GX_IDS_UA_CURNUMFRACT: This user attribute specifies the number of digits that will be allowed to the right of the decimal point.
   format.SetFractionalDigits(_ttoi(pStyle
      ->GetUserAttribute(GX_IDS_UA_CURNUMFRACT)));

See Also

 CGXAbstractControlFactory::RegisterAllUserAttributes  CGXStylesMap::AddUserAttribute

CGXCurrencyEdit

 Class Overview |  Class Members