Colin Finck (mail at colinfinck dot de)

patch to sysdm (id=1161)
fixing truncate of string and making allot better layout of the system info. 


See issue #1858 for more details.

svn path=/trunk/; revision=25012
This commit is contained in:
Magnus Olsen 2006-12-01 17:36:07 +00:00
parent d67835f9dc
commit 817dba67ef
3 changed files with 88 additions and 31 deletions

View file

@ -11,10 +11,11 @@ BEGIN
LTEXT "Version ", IDC_STATIC, 10, 153, 25, 9 LTEXT "Version ", IDC_STATIC, 10, 153, 25, 9
LTEXT REACTOS_STR_PRODUCT_VERSION, IDC_STATIC, 35, 153, 91, 9 LTEXT REACTOS_STR_PRODUCT_VERSION, IDC_STATIC, 35, 153, 91, 9
LTEXT "Machine:", IDC_STATIC, 124, 132, 34, 9 LTEXT "Machine:", IDC_STATIC, 124, 132, 34, 9
LTEXT "", IDC_PROCESSORMANUFACTURER, 130, 144, 118, 9 LTEXT "", IDC_MACHINELINE1, 130, 144, 118, 9
LTEXT "", IDC_PROCESSOR, 130, 153, 118, 9 LTEXT "", IDC_MACHINELINE2, 130, 153, 118, 9
LTEXT "", IDC_PROCESSORSPEED, 130, 162, 118, 9 LTEXT "", IDC_MACHINELINE3, 130, 162, 118, 9
LTEXT "", IDC_SYSTEMMEMORY, 130, 171, 118, 9 LTEXT "", IDC_MACHINELINE4, 130, 171, 118, 9
LTEXT "", IDC_MACHINELINE5, 130, 180, 118, 9
LTEXT "Visit the ReactOS Homepage", IDC_ROSHOMEPAGE_LINK, 20, 200, 93, 8 LTEXT "Visit the ReactOS Homepage", IDC_ROSHOMEPAGE_LINK, 20, 200, 93, 8
PUSHBUTTON "View licence...", IDC_LICENCE, 170, 199, 78, 13 PUSHBUTTON "View licence...", IDC_LICENCE, 170, 199, 78, 13
END END

View file

@ -5,6 +5,7 @@
* PURPOSE: General System Information * PURPOSE: General System Information
* COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org> * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com> * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
* Copyright 2006 Colin Finck <mail@colinfinck.de>
* *
*/ */
@ -110,15 +111,20 @@ SetRegTextData(HWND hwnd,
} }
} }
static VOID static INT
SetProcName(HWND hwnd, SetProcNameString(HWND hwnd,
HKEY hKey, HKEY hKey,
LPTSTR Value, LPTSTR Value,
UINT uID) UINT uID1,
UINT uID2)
{ {
LPTSTR lpBuf = NULL; LPTSTR lpBuf = NULL;
DWORD BufSize = 0; DWORD BufSize = 0;
DWORD Type; DWORD Type;
INT Ret = 0;
TCHAR szBuf[31];
TCHAR* szLastSpace;
INT LastSpace = 0;
if (RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
Value, Value,
@ -130,7 +136,7 @@ SetProcName(HWND hwnd,
lpBuf = HeapAlloc(GetProcessHeap(), lpBuf = HeapAlloc(GetProcessHeap(),
0, 0,
BufSize); BufSize);
if (!lpBuf) return; if (!lpBuf) return 0;
if (RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
Value, Value,
@ -139,15 +145,56 @@ SetProcName(HWND hwnd,
(PBYTE)lpBuf, (PBYTE)lpBuf,
&BufSize) == ERROR_SUCCESS) &BufSize) == ERROR_SUCCESS)
{ {
if(BufSize > ((30 + 1) * sizeof(TCHAR)))
{
/* Wrap the Processor Name String like XP does: *
* - Take the first 30 characters and look for the last space. *
* Then wrap the string after this space. *
* - If no space is found, wrap the string after character 30. *
* *
* For example the Processor Name String of a Pentium 4 is right-aligned. *
* With this wrapping the first line looks centered. */
_tcsncpy(szBuf, lpBuf, 30);
szLastSpace = _tcsrchr(szBuf, ' ');
if(szLastSpace == 0)
LastSpace = 30;
else
LastSpace = (szLastSpace - szBuf);
_tcsncpy(szBuf, lpBuf, LastSpace);
szBuf[LastSpace] = 0;
SetDlgItemText(hwnd, SetDlgItemText(hwnd,
uID, uID1,
lpBuf + _tcsspn(lpBuf, _T(" "))); szBuf);
SetDlgItemText(hwnd,
uID2,
lpBuf+LastSpace+1);
/* Return the number of used lines */
Ret = 2;
}
else
{
SetDlgItemText(hwnd,
uID1,
lpBuf);
Ret = 1;
}
} }
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
lpBuf); lpBuf);
return Ret;
} }
return 0;
} }
static VOID static VOID
@ -193,6 +240,7 @@ GetSystemInformation(HWND hwnd)
MEMORYSTATUSEX MemStat; MEMORYSTATUSEX MemStat;
TCHAR Buf[32]; TCHAR Buf[32];
INT Ret = 0; INT Ret = 0;
INT CurMachineLine = IDC_MACHINELINE1;
/* Get Processor information * /* Get Processor information *
@ -209,17 +257,21 @@ GetSystemInformation(HWND hwnd)
SetRegTextData(hwnd, SetRegTextData(hwnd,
hKey, hKey,
_T("VendorIdentifier"), _T("VendorIdentifier"),
IDC_PROCESSORMANUFACTURER); CurMachineLine);
CurMachineLine++;
SetProcName(hwnd, Ret = SetProcNameString(hwnd,
hKey, hKey,
_T("ProcessorNameString"), _T("ProcessorNameString"),
IDC_PROCESSOR); CurMachineLine,
CurMachineLine+1);
CurMachineLine += Ret;
SetProcSpeed(hwnd, SetProcSpeed(hwnd,
hKey, hKey,
_T("~MHz"), _T("~MHz"),
IDC_PROCESSORSPEED); CurMachineLine);
CurMachineLine++;
} }
@ -279,7 +331,7 @@ GetSystemInformation(HWND hwnd)
if (Ret) if (Ret)
{ {
SetDlgItemText(hwnd, SetDlgItemText(hwnd,
IDC_SYSTEMMEMORY, CurMachineLine,
Buf); Buf);
} }
} }
@ -363,3 +415,6 @@ GeneralPageProc(HWND hwndDlg,
} }

View file

@ -22,13 +22,14 @@
/* propsheet - general */ /* propsheet - general */
#define IDD_PROPPAGEGENERAL 100 #define IDD_PROPPAGEGENERAL 100
#define IDC_PROCESSORMANUFACTURER 101 #define IDC_MACHINELINE1 101
#define IDC_PROCESSOR 102 #define IDC_MACHINELINE2 102
#define IDC_PROCESSORSPEED 103 #define IDC_MACHINELINE3 103
#define IDC_SYSTEMMEMORY 104 #define IDC_MACHINELINE4 104
#define IDC_LICENCE 105 #define IDC_MACHINELINE5 105
#define IDC_ROSIMG 106 #define IDC_LICENCE 106
#define IDC_ROSHOMEPAGE_LINK 107 #define IDC_ROSIMG 107
#define IDC_ROSHOMEPAGE_LINK 108
/* propsheet - computer name */ /* propsheet - computer name */