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 REACTOS_STR_PRODUCT_VERSION, IDC_STATIC, 35, 153, 91, 9
LTEXT "Machine:", IDC_STATIC, 124, 132, 34, 9
LTEXT "", IDC_PROCESSORMANUFACTURER, 130, 144, 118, 9
LTEXT "", IDC_PROCESSOR, 130, 153, 118, 9
LTEXT "", IDC_PROCESSORSPEED, 130, 162, 118, 9
LTEXT "", IDC_SYSTEMMEMORY, 130, 171, 118, 9
LTEXT "", IDC_MACHINELINE1, 130, 144, 118, 9
LTEXT "", IDC_MACHINELINE2, 130, 153, 118, 9
LTEXT "", IDC_MACHINELINE3, 130, 162, 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
PUSHBUTTON "View licence...", IDC_LICENCE, 170, 199, 78, 13
END

View file

@ -5,6 +5,7 @@
* PURPOSE: General System Information
* COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
* Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
* Copyright 2006 Colin Finck <mail@colinfinck.de>
*
*/
@ -110,16 +111,21 @@ SetRegTextData(HWND hwnd,
}
}
static VOID
SetProcName(HWND hwnd,
HKEY hKey,
LPTSTR Value,
UINT uID)
static INT
SetProcNameString(HWND hwnd,
HKEY hKey,
LPTSTR Value,
UINT uID1,
UINT uID2)
{
LPTSTR lpBuf = NULL;
DWORD BufSize = 0;
DWORD Type;
INT Ret = 0;
TCHAR szBuf[31];
TCHAR* szLastSpace;
INT LastSpace = 0;
if (RegQueryValueEx(hKey,
Value,
NULL,
@ -129,8 +135,8 @@ SetProcName(HWND hwnd,
{
lpBuf = HeapAlloc(GetProcessHeap(),
0,
BufSize);
if (!lpBuf) return;
BufSize);
if (!lpBuf) return 0;
if (RegQueryValueEx(hKey,
Value,
@ -139,15 +145,56 @@ SetProcName(HWND hwnd,
(PBYTE)lpBuf,
&BufSize) == ERROR_SUCCESS)
{
SetDlgItemText(hwnd,
uID,
lpBuf + _tcsspn(lpBuf, _T(" ")));
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,
uID1,
szBuf);
SetDlgItemText(hwnd,
uID2,
lpBuf+LastSpace+1);
/* Return the number of used lines */
Ret = 2;
}
else
{
SetDlgItemText(hwnd,
uID1,
lpBuf);
Ret = 1;
}
}
HeapFree(GetProcessHeap(),
0,
lpBuf);
return Ret;
}
return 0;
}
static VOID
@ -193,6 +240,7 @@ GetSystemInformation(HWND hwnd)
MEMORYSTATUSEX MemStat;
TCHAR Buf[32];
INT Ret = 0;
INT CurMachineLine = IDC_MACHINELINE1;
/* Get Processor information *
@ -209,17 +257,21 @@ GetSystemInformation(HWND hwnd)
SetRegTextData(hwnd,
hKey,
_T("VendorIdentifier"),
IDC_PROCESSORMANUFACTURER);
SetProcName(hwnd,
hKey,
_T("ProcessorNameString"),
IDC_PROCESSOR);
CurMachineLine);
CurMachineLine++;
Ret = SetProcNameString(hwnd,
hKey,
_T("ProcessorNameString"),
CurMachineLine,
CurMachineLine+1);
CurMachineLine += Ret;
SetProcSpeed(hwnd,
hKey,
_T("~MHz"),
IDC_PROCESSORSPEED);
CurMachineLine);
CurMachineLine++;
}
@ -279,7 +331,7 @@ GetSystemInformation(HWND hwnd)
if (Ret)
{
SetDlgItemText(hwnd,
IDC_SYSTEMMEMORY,
CurMachineLine,
Buf);
}
}
@ -363,3 +415,6 @@ GeneralPageProc(HWND hwndDlg,
}

View file

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