mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 11:53:16 +00:00
Import the new code for showing floating point values with the correct decimal separator from shell32.
sysdm.cpl now shows the processor speed and RAM size values with the correct decimal separator based on the current locale. svn path=/trunk/; revision=29925
This commit is contained in:
parent
1d824ac4f3
commit
1b5d11010e
1 changed files with 41 additions and 26 deletions
|
@ -198,12 +198,32 @@ SetProcNameString(HWND hwnd,
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
MakeFloatValueString(double* dFloatValue,
|
||||||
|
LPTSTR szOutput,
|
||||||
|
LPTSTR szAppend)
|
||||||
|
{
|
||||||
|
TCHAR szDecimalSeparator[4];
|
||||||
|
|
||||||
|
// Get the decimal separator for the current locale
|
||||||
|
if( GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, szDecimalSeparator, sizeof(szDecimalSeparator) / sizeof(TCHAR)) > 0)
|
||||||
|
{
|
||||||
|
UCHAR uDecimals;
|
||||||
|
UINT uIntegral;
|
||||||
|
|
||||||
|
// Show the value with two decimals
|
||||||
|
uIntegral = (UINT)*dFloatValue;
|
||||||
|
uDecimals = (UCHAR)((UINT)(*dFloatValue * 100) - uIntegral * 100);
|
||||||
|
|
||||||
|
wsprintf(szOutput, _T("%u%s%02u %s"), uIntegral, szDecimalSeparator, uDecimals, szAppend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
SetProcSpeed(HWND hwnd,
|
SetProcSpeed(HWND hwnd,
|
||||||
HKEY hKey,
|
HKEY hKey,
|
||||||
LPTSTR Value,
|
LPTSTR Value,
|
||||||
UINT uID)
|
UINT uID)
|
||||||
|
|
||||||
{
|
{
|
||||||
TCHAR szBuf[64];
|
TCHAR szBuf[64];
|
||||||
DWORD BufSize = sizeof(DWORD);
|
DWORD BufSize = sizeof(DWORD);
|
||||||
|
@ -228,12 +248,12 @@ SetProcSpeed(HWND hwnd,
|
||||||
{
|
{
|
||||||
if (ppi.CurrentMhz < 1000)
|
if (ppi.CurrentMhz < 1000)
|
||||||
{
|
{
|
||||||
_stprintf(szBuf, _T("%lu MHz"), ppi.CurrentMhz);
|
wsprintf(szBuf, _T("%lu MHz"), ppi.CurrentMhz);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double flt = ppi.CurrentMhz / 1000.0;
|
double flt = ppi.CurrentMhz / 1000.0;
|
||||||
_stprintf(szBuf, _T("%.2f GHz"), flt);
|
MakeFloatValueString(&flt, szBuf, _T("GHz"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDlgItemText(hwnd,
|
SetDlgItemText(hwnd,
|
||||||
|
@ -289,29 +309,28 @@ GetSystemInformation(HWND hwnd)
|
||||||
{
|
{
|
||||||
TCHAR szStr[32];
|
TCHAR szStr[32];
|
||||||
double dTotalPhys;
|
double dTotalPhys;
|
||||||
|
|
||||||
|
if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
|
||||||
|
{
|
||||||
UINT i = 0;
|
UINT i = 0;
|
||||||
static const UINT uStrId[] = {
|
static const UINT uStrId[] = {
|
||||||
IDS_MEGABYTE,
|
|
||||||
IDS_GIGABYTE,
|
IDS_GIGABYTE,
|
||||||
IDS_TERABYTE,
|
IDS_TERABYTE,
|
||||||
IDS_PETABYTE
|
IDS_PETABYTE
|
||||||
};
|
};
|
||||||
|
|
||||||
if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
|
// We're dealing with GBs or more
|
||||||
{
|
|
||||||
/* We're dealing with GBs or more */
|
|
||||||
MemStat.ullTotalPhys /= 1024 * 1024;
|
MemStat.ullTotalPhys /= 1024 * 1024;
|
||||||
i++;
|
|
||||||
|
|
||||||
if (MemStat.ullTotalPhys > 1024 * 1024)
|
if (MemStat.ullTotalPhys > 1024 * 1024)
|
||||||
{
|
{
|
||||||
/* We're dealing with TBs or more */
|
// We're dealing with TBs or more
|
||||||
MemStat.ullTotalPhys /= 1024;
|
MemStat.ullTotalPhys /= 1024;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
if (MemStat.ullTotalPhys > 1024 * 1024)
|
if (MemStat.ullTotalPhys > 1024 * 1024)
|
||||||
{
|
{
|
||||||
/* We're dealing with PBs or more */
|
// We're dealing with PBs or more
|
||||||
MemStat.ullTotalPhys /= 1024;
|
MemStat.ullTotalPhys /= 1024;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
@ -322,22 +341,18 @@ GetSystemInformation(HWND hwnd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
|
dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
|
||||||
|
|
||||||
|
LoadString(hApplet, uStrId[i], szStr, sizeof(szStr) / sizeof(TCHAR));
|
||||||
|
MakeFloatValueString(&dTotalPhys, Buf, szStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* We're daling with MBs */
|
// We're dealing with MBs, don't show any decimals
|
||||||
dTotalPhys = (double)MemStat.ullTotalPhys / 1024 / 1024;
|
LoadString(hApplet, IDS_MEGABYTE, szStr, sizeof(szStr) / sizeof(TCHAR));
|
||||||
|
wsprintf(Buf, _T("%u %s"), (UINT)MemStat.ullTotalPhys / 1024 / 1024, szStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoadString(hApplet, uStrId[i], szStr, sizeof(szStr) / sizeof(szStr[0])))
|
SetDlgItemText(hwnd, CurMachineLine, Buf);
|
||||||
{
|
|
||||||
if( _stprintf(Buf, _T("%.2f %s"), dTotalPhys, szStr) )
|
|
||||||
{
|
|
||||||
SetDlgItemText(hwnd,
|
|
||||||
CurMachineLine,
|
|
||||||
Buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue