Huw Davies : comdlg32: Switch to using a locale dependent decimal separator .
Alexandre Julliard
julliard at winehq.org
Tue Jan 20 08:27:45 CST 2009
Module: wine
Branch: master
Commit: 276434caa9264d20cf962966f06516c15c244404
URL: http://source.winehq.org/git/wine.git/?a=commit;h=276434caa9264d20cf962966f06516c15c244404
Author: Huw Davies <huw at codeweavers.com>
Date: Mon Jan 19 14:28:43 2009 +0000
comdlg32: Switch to using a locale dependent decimal separator.
---
dlls/comdlg32/printdlg.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c
index 54de61e..f9f1ba1 100644
--- a/dlls/comdlg32/printdlg.c
+++ b/dlls/comdlg32/printdlg.c
@@ -2416,26 +2416,38 @@ _c_inch2size(PAGESETUPDLGA *dlga,DWORD size) {
return (size*254)/100;
}
+static WCHAR get_decimal_sep(void)
+{
+ static WCHAR sep;
+
+ if(!sep)
+ {
+ WCHAR buf[2] = {'.',0};
+ GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buf, sizeof(buf) / sizeof(buf[0]));
+ sep = buf[0];
+ }
+ return sep;
+}
+
static void size2str(const PageSetupDataA *pda, DWORD size, LPWSTR strout)
{
- WCHAR decimal[2] = {'.', 0};
WCHAR integer_fmt[] = {'%','d',0};
- WCHAR hundredths_fmt[] = {'%','d','%','s','%','0','2','d',0};
- WCHAR thousandths_fmt[] = {'%','d','%','s','%','0','3','d',0};
+ WCHAR hundredths_fmt[] = {'%','d','%','c','%','0','2','d',0};
+ WCHAR thousandths_fmt[] = {'%','d','%','c','%','0','3','d',0};
/* FIXME use LOCALE_SDECIMAL when the edit parsing code can cope */
if (is_metric(pda))
{
if(size % 100)
- wsprintfW(strout, hundredths_fmt, size / 100, decimal, size % 100);
+ wsprintfW(strout, hundredths_fmt, size / 100, get_decimal_sep(), size % 100);
else
wsprintfW(strout, integer_fmt, size / 100);
}
else
{
if(size % 1000)
- wsprintfW(strout, thousandths_fmt, size / 1000, decimal, size % 1000);
+ wsprintfW(strout, thousandths_fmt, size / 1000, get_decimal_sep(), size % 1000);
else
wsprintfW(strout, integer_fmt, size / 1000);
@@ -2896,7 +2908,7 @@ static void margin_edit_notification(HWND hDlg, PageSetupDataA *pda, WORD msg, W
if (GetDlgItemTextW(hDlg, id, buf, sizeof(buf) / sizeof(buf[0])) != 0)
{
WCHAR *end;
- WCHAR decimal = '.';
+ WCHAR decimal = get_decimal_sep();
val = strtolW(buf, &end, 10);
if(end != buf || *end == decimal)
@@ -3351,13 +3363,10 @@ PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
*/
static LRESULT CALLBACK pagesetup_margin_editproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
- WCHAR decimal = '.';
-
- /* FIXME use LOCALE_SDECIMAL when the edit parsing code can cope */
-
switch(msg)
case WM_CHAR:
{
+ WCHAR decimal = get_decimal_sep();
WCHAR wc = (WCHAR)wparam;
if(!isdigitW(wc) && wc != decimal && wc != VK_BACK) return 0;
}
More information about the wine-cvs
mailing list