ReactOS 0.4.15-dev-8116-gf69e256
currency.c File Reference
#include "intl.h"
Include dependency graph for currency.c:

Go to the source code of this file.

Macros

#define POSITIVE_EXAMPLE   L"123456789.00"
 
#define NEGATIVE_EXAMPLE   L"-123456789.00"
 

Functions

static VOID UpdateExamples (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencySymbols (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencyPositiveFormats (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencyNegativeFormats (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencyDecimalSeparators (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencyNumFracDigits (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitCurrencyGroupSeparators (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static VOID InitDigitGroupCB (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
static BOOL GetCurrencySetting (HWND hwndDlg, PGLOBALDATA pGlobalData)
 
INT_PTR CALLBACK CurrencyPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ NEGATIVE_EXAMPLE

#define NEGATIVE_EXAMPLE   L"-123456789.00"

Definition at line 30 of file currency.c.

◆ POSITIVE_EXAMPLE

#define POSITIVE_EXAMPLE   L"123456789.00"

Definition at line 29 of file currency.c.

Function Documentation

◆ CurrencyPageProc()

INT_PTR CALLBACK CurrencyPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 351 of file currency.c.

355{
356 PGLOBALDATA pGlobalData;
357
358 pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
359
360 switch (uMsg)
361 {
362 case WM_INITDIALOG:
363 pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
364 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
365
366 InitCurrencySymbols(hwndDlg, pGlobalData);
367 InitCurrencyPositiveFormats(hwndDlg, pGlobalData);
368 InitCurrencyNegativeFormats(hwndDlg, pGlobalData);
369 InitCurrencyDecimalSeparators(hwndDlg, pGlobalData);
370 InitCurrencyNumFracDigits(hwndDlg, pGlobalData);
371 InitCurrencyGroupSeparators(hwndDlg, pGlobalData);
372 InitDigitGroupCB(hwndDlg, pGlobalData);
373 UpdateExamples(hwndDlg, pGlobalData);
374 break;
375
376 case WM_COMMAND:
377 switch (LOWORD(wParam))
378 {
386 if (HIWORD(wParam) == CBN_SELCHANGE ||
388 {
389 /* Enable the Apply button */
390 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
391 }
392 }
393 break;
394
395 case WM_NOTIFY:
396 if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
397 {
398 if (GetCurrencySetting(hwndDlg, pGlobalData))
399 {
400 pGlobalData->bUserLocaleChanged = TRUE;
401 UpdateExamples(hwndDlg, pGlobalData);
402 }
403 }
404 break;
405 }
406 return FALSE;
407}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
static VOID InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:229
static VOID InitCurrencyGroupSeparators(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:207
static VOID InitCurrencyPositiveFormats(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:87
static VOID InitCurrencySymbols(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:65
static VOID InitCurrencyNumFracDigits(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:182
static VOID UpdateExamples(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:34
static VOID InitCurrencyDecimalSeparators(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:159
static VOID InitCurrencyNegativeFormats(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:123
static BOOL GetCurrencySetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
Definition: currency.c:266
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_CURRENCYSYMBOL
Definition: resource.h:27
#define IDC_CURRENCYNEGVALUE
Definition: resource.h:29
#define IDC_CURRENCYDECNUM
Definition: resource.h:31
#define IDC_CURRENCYGRPNUM
Definition: resource.h:33
#define IDC_CURRENCYPOSVALUE
Definition: resource.h:28
#define IDC_CURRENCYGRPSEP
Definition: resource.h:32
#define IDC_CURRENCYDECSEP
Definition: resource.h:30
struct _GLOBALDATA * PGLOBALDATA
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define WM_NOTIFY
Definition: richedit.h:61
BOOL bUserLocaleChanged
Definition: intl.h:115
Definition: inflate.c:139
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
#define DWLP_USER
Definition: winuser.h:872
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define CBN_SELCHANGE
Definition: winuser.h:1979
HWND WINAPI GetParent(_In_ HWND)
#define CBN_EDITCHANGE
Definition: winuser.h:1975

Referenced by CustomizeLocalePropertySheet().

◆ GetCurrencySetting()

static BOOL GetCurrencySetting ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 266 of file currency.c.

269{
270 WCHAR szCurrSymbol[MAX_CURRSYMBOL];
271 WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP];
272 WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP];
273 INT nCurrPosFormat;
274 INT nCurrNegFormat;
275 INT nCurrDigits;
276 INT nCurrGrouping;
277
278 /* Currency symbol */
281 szCurrSymbol,
283
284 if (szCurrSymbol[0] == L'\0')
285 {
286 /* TODO: Show error message */
287
288 return FALSE;
289 }
290
291 /* Positive Amount */
294 &nCurrPosFormat);
295
296 /* Negative Amount */
299 &nCurrNegFormat);
300
301 /* Decimal separator */
304 szCurrDecimalSep,
306
307 if (szCurrDecimalSep[0] == L'\0')
308 {
309 /* TODO: Show error message */
310
311 return FALSE;
312 }
313
314 /* Number of fractional digits */
317 &nCurrDigits);
318
319 /* Grouping symbol */
322 szCurrThousandSep,
324
325 if (szCurrThousandSep[0] == L'\0')
326 {
327 /* TODO: Show error message */
328
329 return FALSE;
330 }
331
332 /* Digit grouping */
335 &nCurrGrouping);
336
337 /* Store settings in global data */
338 wcscpy(pGlobalData->szCurrSymbol, szCurrSymbol);
339 pGlobalData->nCurrGrouping = nCurrGrouping;
340 wcscpy(pGlobalData->szCurrDecimalSep, szCurrDecimalSep);
341 wcscpy(pGlobalData->szCurrThousandSep, szCurrThousandSep);
342 pGlobalData->nCurrPosFormat = nCurrPosFormat;
343 pGlobalData->nCurrNegFormat = nCurrNegFormat;
344 pGlobalData->nCurrDigits = nCurrDigits;
345
346 return TRUE;
347}
VOID GetSelectedComboBoxText(HWND hwndDlg, INT nIdDlgItem, PWSTR Buffer, UINT uSize)
Definition: misc.c:176
VOID GetSelectedComboBoxIndex(HWND hwndDlg, INT nIdDlgItem, PINT pValue)
Definition: misc.c:223
#define MAX_CURRSYMBOL
Definition: intl.h:33
#define MAX_CURRTHOUSANDSEP
Definition: intl.h:35
#define MAX_CURRDECIMALSEP
Definition: intl.h:34
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP]
Definition: intl.h:83
INT nCurrGrouping
Definition: intl.h:87
INT nCurrDigits
Definition: intl.h:86
WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP]
Definition: intl.h:82
INT nCurrPosFormat
Definition: intl.h:84
WCHAR szCurrSymbol[MAX_CURRSYMBOL]
Definition: intl.h:81
INT nCurrNegFormat
Definition: intl.h:85
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CurrencyPageProc().

◆ InitCurrencyDecimalSeparators()

static VOID InitCurrencyDecimalSeparators ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 159 of file currency.c.

160{
161 /* Limit text length */
165 0);
166
167 /* Decimal separator */
170 0,
171 (LPARAM)pGlobalData->szCurrDecimalSep);
172
175 0, /* Index */
176 0);
177}
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_SETCURSEL
Definition: winuser.h:1961
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_LIMITTEXT
Definition: winuser.h:1958

Referenced by CurrencyPageProc().

◆ InitCurrencyGroupSeparators()

static VOID InitCurrencyGroupSeparators ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 207 of file currency.c.

208{
209 /* Limit text length */
213 0);
214
215 /* Digit group separator */
218 0,
219 (LPARAM)pGlobalData->szCurrThousandSep);
220
223 0, /* Index */
224 0);
225}

Referenced by CurrencyPageProc().

◆ InitCurrencyNegativeFormats()

static VOID InitCurrencyNegativeFormats ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 123 of file currency.c.

124{
125 WCHAR szBuffer[MAX_FMT_SIZE];
126 CURRENCYFMTW cyFmt;
127 int i;
128
129 /* negative currency values */
130 cyFmt.NumDigits = pGlobalData->nCurrDigits;
131 cyFmt.LeadingZero = 0;
132 cyFmt.Grouping = 3;
133 cyFmt.lpDecimalSep = pGlobalData->szCurrDecimalSep;
134 cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep;
135 cyFmt.lpCurrencySymbol = pGlobalData->szCurrSymbol;
136 cyFmt.PositiveOrder = 0;
137
138 for (i = 0; i < 16; i++)
139 {
140 cyFmt.NegativeOrder = i;
141 GetCurrencyFormatW(pGlobalData->UserLCID, 0,
142 L"-1.1",
143 &cyFmt, szBuffer, MAX_FMT_SIZE);
144
147 -1,
148 (LPARAM)szBuffer);
149 }
150
153 pGlobalData->nCurrNegFormat,
154 0);
155}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define MAX_FMT_SIZE
Definition: intl.h:22
INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const CURRENCYFMTW *lpFormat, LPWSTR lpCurrencyStr, int cchOut)
Definition: lcformat.c:1578
LCID UserLCID
Definition: intl.h:113
UINT LeadingZero
Definition: winnls.h:613
LPWSTR lpDecimalSep
Definition: winnls.h:615
UINT NumDigits
Definition: winnls.h:612
LPWSTR lpCurrencySymbol
Definition: winnls.h:619
UINT PositiveOrder
Definition: winnls.h:618
UINT Grouping
Definition: winnls.h:614
UINT NegativeOrder
Definition: winnls.h:617
LPWSTR lpThousandSep
Definition: winnls.h:616
#define CB_INSERTSTRING
Definition: winuser.h:1957

Referenced by CurrencyPageProc().

◆ InitCurrencyNumFracDigits()

static VOID InitCurrencyNumFracDigits ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 182 of file currency.c.

183{
184 WCHAR szBuffer[MAX_FMT_SIZE];
185 int i;
186
187 /* Create standard list of fractional symbols */
188 for (i = 0; i < 10; i++)
189 {
190 szBuffer[0] = L'0' + i;
191 szBuffer[1] = 0;
194 0,
195 (LPARAM)szBuffer);
196 }
197
200 pGlobalData->nCurrDigits,
201 0);
202}

Referenced by CurrencyPageProc().

◆ InitCurrencyPositiveFormats()

static VOID InitCurrencyPositiveFormats ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 87 of file currency.c.

88{
89 WCHAR szBuffer[MAX_FMT_SIZE];
90 CURRENCYFMTW cyFmt;
91 INT i;
92
93 /* positive currency values */
94 cyFmt.NumDigits = pGlobalData->nCurrDigits;
95 cyFmt.LeadingZero = 0;
96 cyFmt.Grouping = 3;
97 cyFmt.lpDecimalSep = pGlobalData->szCurrDecimalSep;
98 cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep;
99 cyFmt.lpCurrencySymbol = pGlobalData->szCurrSymbol;
100 cyFmt.NegativeOrder = 0;
101
102 for (i = 0; i < 4; i++)
103 {
104 cyFmt.PositiveOrder = i;
105 GetCurrencyFormatW(pGlobalData->UserLCID, 0,
106 L"1.1",
107 &cyFmt, szBuffer, MAX_FMT_SIZE);
108
111 -1,
112 (LPARAM)szBuffer);
113 }
114
117 pGlobalData->nCurrPosFormat,
118 0);
119}

Referenced by CurrencyPageProc().

◆ InitCurrencySymbols()

static VOID InitCurrencySymbols ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 65 of file currency.c.

66{
67 /* Limit text length */
71 0);
72
73 /* Set currency symbols */
76 0,
77 (LPARAM)pGlobalData->szCurrSymbol);
78
81 0, /* Index */
82 0);
83}

Referenced by CurrencyPageProc().

◆ InitDigitGroupCB()

static VOID InitDigitGroupCB ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 229 of file currency.c.

230{
231 WCHAR szBuffer[MAX_FMT_SIZE];
232 CURRENCYFMTW cyFmt;
233 INT i;
234
235 /* Digit grouping */
236 cyFmt.NumDigits = 0;
237 cyFmt.LeadingZero = 0;
238 cyFmt.lpDecimalSep = L"";
239 cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep;
240 cyFmt.PositiveOrder = 0;
241 cyFmt.NegativeOrder = 0;
242 cyFmt.lpCurrencySymbol = L"";
243
244 for (i = 0 ; i < MAX_GROUPINGFORMATS ; i++)
245 {
247
248 GetCurrencyFormatW(pGlobalData->UserLCID, 0,
249 L"123456789",
250 &cyFmt, szBuffer, MAX_FMT_SIZE);
253 -1,
254 (LPARAM)szBuffer);
255 }
256
259 pGlobalData->nCurrGrouping,
260 0);
261}
GROUPINGDATA GroupingFormats[MAX_GROUPINGFORMATS]
Definition: generalp.c:44
#define MAX_GROUPINGFORMATS
Definition: intl.h:51
UINT nInteger
Definition: intl.h:127

Referenced by CurrencyPageProc().

◆ UpdateExamples()

static VOID UpdateExamples ( HWND  hwndDlg,
PGLOBALDATA  pGlobalData 
)
static

Definition at line 34 of file currency.c.

35{
36 WCHAR szBuffer[MAX_FMT_SIZE];
37 CURRENCYFMTW CurrencyFormat;
38
39 CurrencyFormat.NumDigits = pGlobalData->nCurrDigits;
40 CurrencyFormat.LeadingZero = pGlobalData->nNumLeadingZero;
41 CurrencyFormat.Grouping = GroupingFormats[pGlobalData->nCurrGrouping].nInteger;
42 CurrencyFormat.lpDecimalSep = pGlobalData->szCurrDecimalSep;
43 CurrencyFormat.lpThousandSep = pGlobalData->szCurrThousandSep;
44 CurrencyFormat.NegativeOrder = pGlobalData->nCurrNegFormat;
45 CurrencyFormat.PositiveOrder = pGlobalData->nCurrPosFormat;
46 CurrencyFormat.lpCurrencySymbol = pGlobalData->szCurrSymbol;
47
48 /* Positive example */
49 GetCurrencyFormatW(pGlobalData->UserLCID, 0,
51 &CurrencyFormat, szBuffer, MAX_FMT_SIZE);
52
54
55 /* Negative example */
56 GetCurrencyFormatW(pGlobalData->UserLCID, 0,
58 &CurrencyFormat, szBuffer, MAX_FMT_SIZE);
59
61}
#define POSITIVE_EXAMPLE
Definition: currency.c:29
#define NEGATIVE_EXAMPLE
Definition: currency.c:30
#define IDC_CURRENCYNEGSAMPLE
Definition: resource.h:26
#define IDC_CURRENCYPOSSAMPLE
Definition: resource.h:25
INT nNumLeadingZero
Definition: intl.h:75
#define WM_SETTEXT
Definition: winuser.h:1617

Referenced by CurrencyPageProc().