<< Return to Main Index

< Return to Class Index

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:

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"));

·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]);

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.



   format.SetDecimalDigits(_ttoi(pStyle
   ->GetUserAttribute(GX_IDS_UA_CURNUMDECIMALS)));
   
   format.SetFractionalDigits(_ttoi(pStyle
      ->GetUserAttribute(GX_IDS_UA_CURNUMFRACT)));

See Also

CGXAbstractControlFactory::RegisterAllUserAttributes CGXStylesMap::AddUserAttribute

CGXCurrencyEdit

Class Overview | Class Members