Skip to content

Commit

Permalink
Merge pull request #44 from CherryPill/v1.2
Browse files Browse the repository at this point in the history
Closes #28
  • Loading branch information
CherryPill authored Jul 3, 2017
2 parents f20bbe1 + 25f4103 commit dca8693
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 79 deletions.
Binary file modified .vs/SystemInfo/v14/.suo
Binary file not shown.
3 changes: 3 additions & 0 deletions SystemInfo/SystemInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class SystemInfo {
vector<wstring> getDisplayDevices(void);
vector<NetAdapter> getNetworkAdapters(void);
vector<wstring> getNetworkAdaptersText(void);
vector<wstring>& getNetworkAdaptersTextRef(void) {
return this->networkAdaptersText;
}
wstring getOS(void);
void setBIOS(wstring bios);
void setUptime(wstring uptime);
Expand Down
4 changes: 2 additions & 2 deletions SystemInfo/appconst.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef APPCONST_H
#define APPCONST_H
#define STR_MAX 256
#define ITEM_WIDTH 350
#define ITEM_WIDTH 150
#define ITEM_HEIGHT 40
#define ITEM_INFO_WIDTH 500
#define ITEM_INFO_HEIGHT 400
#define ITEM_INFO_HEIGHT 100

#endif
1 change: 1 addition & 0 deletions SystemInfo/globalVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TCHAR *fontFamilies[] = {
_T("Courier New")
};
HFONT appNameFontLarge = CreateFont(-28, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, fontFamilies[0]);
HFONT ipToggleBtnFont = CreateFont(-10, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, fontFamilies[0]);

TCHAR *timeVerboseMonths[] = {
_T("Dummy"),
Expand Down
7 changes: 5 additions & 2 deletions SystemInfo/globalVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "resource.h"
using namespace std;
extern int PROGRAM_INSTANCE; //0 - parent, 1 - child
extern TCHAR PROGRAM_DATA_IMPORT_LOCATION[256]; //path to the bin file to import data from if the process is spawned by parent
extern TCHAR PROGRAM_DATA_IMPORT_LOCATION[256]; //path to the xml file to import data from if the process is spawned by parent
extern TCHAR execName[256];
extern SoftwareInfo *shippedSoftWare;
extern HINSTANCE ghInstance;
Expand Down Expand Up @@ -62,7 +62,7 @@ static TCHAR *savefileExtensionsLong[5] = {
_T(".txt files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"),
_T(".xml files (*.xml)\0*.xml\0All Files (*.*)\0*.*\0"),
_T(".html files (*.html)\0*.html\0All Files (*.*)\0*.*\0"),
_T(".sysinfo files (*.sysinfo)\0*.sysinfo\0All Files (*.*)\0*.*\0"),
_T(".sysinfo files (*.sysinfo)\0*.sysinfo\0All Files (*.*)\0*.*\0"), //not used
_T(".png images (*.png)\0*.png\0All Files (*.*)\0*.*\0")
};
static wstring RAMFormFactors[24] {
Expand Down Expand Up @@ -120,4 +120,7 @@ static wstring RAMMemoryTypes[26] {
//time functions
extern TCHAR *timeVerboseMonths[];
extern TCHAR *timeVerboseDaysOfWeek[];
//font
extern HFONT ipToggleBtnFont;

#endif
180 changes: 110 additions & 70 deletions SystemInfo/mainWindowProcedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,75 @@
LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
SystemInfo *localMachine = localMachine->getCurrentInstance();
switch (msg) {
case WM_CREATE:{
loadImages();
if (PROGRAM_INSTANCE == 1) {
importData(localMachine->getCurrentInstance());
}
else {
getSystemInformation(localMachine->getCurrentInstance());
}
createHardwareInfoHolders(hwnd, localMachine->getCurrentInstance());
populateInfoHolders(localMachine->getCurrentInstance(), hwnd);
EnumChildWindows(hwnd,
(WNDENUMPROC)SetFont,
case WM_CREATE: {
loadImages();
if (PROGRAM_INSTANCE == 1) {
importData(localMachine->getCurrentInstance());
}
else {
getSystemInformation(localMachine->getCurrentInstance());
}

createHardwareInfoHolders(hwnd, localMachine->getCurrentInstance());
populateInfoHolders(localMachine->getCurrentInstance(), hwnd);

EnumChildWindows(hwnd,
(WNDENUMPROC)SetFont,
(LPARAM)GetStockObject(DEFAULT_GUI_FONT)); //setting the font

return 0;
toggleIpAddress(hwnd, NULL);
return 0;
}

case WM_COMMAND: {
switch (LOWORD(wParam)) {
case ID_FILE_TAKESCREENSHOT: {
takeScreenshot(hwnd);
break;
}
case WM_COMMAND: {
switch (LOWORD(wParam)) {
case ID_FILE_TAKESCREENSHOT: {
takeScreenshot(hwnd);
break;
}
case ID_EXPORT_XML: {
saveSpecs::saveAsXML(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_TXT: {
saveSpecs::saveAsText(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_HTML: {
saveSpecs::saveAsHTML(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_BIN: {
//stub
break;
}
case ID_IMPORT_FROMXML: {
importAsXML(hwnd);
break;
}
case ID_ABOUT: {
DialogBox(ghInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)aboutDlgProc);
break;
}
case ID_FILE_EXIT: {
PostQuitMessage(WM_QUIT);
break;
}
}
case ID_EXPORT_XML: {
saveSpecs::saveAsXML(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_TXT: {
saveSpecs::saveAsText(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_HTML: {
saveSpecs::saveAsHTML(hwnd, localMachine->getCurrentInstance());
break;
}
case ID_EXPORT_BIN: {
//stub
break;
}
case ID_IMPORT_FROMXML: {
importAsXML(hwnd);
break;
}
case WM_CTLCOLORSTATIC: {
HDC hdcStatic = (HDC)wParam;
if ( GetDlgCtrlID((HWND)lParam) < BIOS_INFO) {
SetTextColor(hdcStatic, RGB(125, 207, 246));
case ID_ABOUT: {
DialogBox(ghInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwnd, (DLGPROC)aboutDlgProc);
break;
}
case ID_FILE_EXIT: {
PostQuitMessage(WM_QUIT);
break;
}
case AUX_IP_TOGGLE: {
toggleIpAddress(hwnd, localMachine);
break;
}
}
}
case WM_CTLCOLORSTATIC: {
HDC hdcStatic = (HDC)wParam;
if (GetDlgCtrlID((HWND)lParam) < BIOS_INFO) {
SetTextColor(hdcStatic, RGB(125, 207, 246));
}
else {
if (GetDlgCtrlID((HWND)lParam) == AUX_IP_TOGGLE){
SetTextColor(hdcStatic, RGB(255, 0, 0));

}
else {
SetTextColor(hdcStatic, RGB(255, 255, 255));
}
SetBkColor(hdcStatic, RGB(81, 81, 81));
Expand All @@ -95,6 +104,9 @@ LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
}
BOOL CALLBACK SetFont(HWND child, LPARAM font) {
SendMessage(child, WM_SETFONT, (LPARAM)GetStockObject(DEFAULT_GUI_FONT), TRUE);
SendMessage(GetDlgItem(GetParent(child), AUX_IP_TOGGLE),
WM_SETFONT,
(WPARAM)ipToggleBtnFont, MAKELPARAM(true, 0));
return TRUE;
}
void loadImages(void) {
Expand All @@ -110,7 +122,7 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info) {
int xStartOffSetLabel = 80;
int xStartOffSetInformation = xStartOffSetLabel + 25 ;
//labels + information as a table
for (int x = 0, y = BIOS_INFO,z=BIOS_ICON_LABEL;x<BIOS_INFO;x++,y++,z++) {
for (int x = BIOS_LABEL, y = BIOS_INFO,z=BIOS_ICON_LABEL;x<BIOS_INFO;x++,y++,z++) {
//icon
CreateWindowEx
(
Expand Down Expand Up @@ -152,13 +164,16 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info) {
NULL,
NULL
);
if (x == 9) {
createIPToggleControl(parent, xStartOffSetLabel+140, yStartOffSet);
}
//info
CreateWindowEx(
0,
L"Static",
(L"Detecting..."+itemStrings[x]).c_str(),
WS_VISIBLE | WS_CHILD |SS_LEFT | DS_SETFONT,
xStartOffSetInformation,
xStartOffSetInformation+5,
yStartOffSet+16,
ITEM_INFO_WIDTH,
ITEM_INFO_HEIGHT,
Expand All @@ -176,7 +191,6 @@ void createHardwareInfoHolders(HWND parent, SystemInfo *info) {
}
}
yStartOffSet += (ITEM_HEIGHT + 2);
int sentinel = 0xf;
}
scrollFullPageHeight = yStartOffSet;
}
Expand Down Expand Up @@ -207,29 +221,55 @@ void populateInfoHolders(SystemInfo *currentMachineInfo, HWND mainWindowHwnd) {
SetWindowText(GetDlgItem(mainWindowHwnd, NETWORK_INFO),
formListString(currentMachineInfo,
HARDWARE_VECTOR_TYPE::HARDWARE_NETWORK, WRITE_OUT_TYPE::APP_WINDOW).c_str());
//if (currentMachineInfo->getNetworkAdaptersText().back().find(L"Unable") == string::npos) {
if (currentMachineInfo->getNetworkAdaptersText().back().find(L"Unable") == string::npos) {
//createIPToggleControl(GetDlgItem(mainWindowHwnd, NETWORK_INFO));
//}
}
SetWindowText(GetDlgItem(mainWindowHwnd, AUDIO_INFO),
currentMachineInfo->getAudio().c_str());
SetWindowText(GetDlgItem(mainWindowHwnd, UPTIME_INFO),
currentMachineInfo->getUptime().c_str());
}
/*
void createIPToggleControl(HWND parent) {

void createIPToggleControl(HWND parent, int xOff, int yOff) {
CreateWindowEx(
0,
L"Static",
L"Hide IP",
WS_VISIBLE | WS_CHILD | SS_CENTER | DS_SETFONT,
20,
20,
L"Button",
ipToggleText[0].c_str(),
WS_VISIBLE | WS_CHILD | WS_TABSTOP,
xOff,
yOff,
64,
20,
15,
parent,
(HMENU)AUX_IP_TOGGLE,
NULL,
NULL
);

}
*/
void toggleIpAddress(HWND mainWindow, SystemInfo *info) {
static bool showStatus = 0;
static wstring savedIP;
SetWindowText(GetDlgItem(mainWindow, AUX_IP_TOGGLE), ipToggleText[showStatus].c_str());
if (info != NULL) {

if (!showStatus) {
info->getNetworkAdaptersTextRef().back().assign(savedIP);
}
else {
savedIP.assign(info->getNetworkAdaptersText().back());
//hide ip
info->getNetworkAdaptersTextRef().back().clear();
info->getNetworkAdaptersTextRef().back().assign(L"Connected to the Internet: (IP hidden by user)");

}
trimWhiteSpace(info->getNetworkAdaptersTextRef().back());
updateNetworkAdaptersView(info);
}
showStatus = !showStatus;
}
void updateNetworkAdaptersView(SystemInfo *currentMachineInfo) {
SetWindowText(GetDlgItem(mainWindowHwnd, NETWORK_INFO),
formListString(currentMachineInfo,
HARDWARE_VECTOR_TYPE::HARDWARE_NETWORK, WRITE_OUT_TYPE::APP_WINDOW).c_str());
}
4 changes: 3 additions & 1 deletion SystemInfo/mainWindowProcedure.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ LRESULT CALLBACK mainWindowProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK SetFont(HWND child, LPARAM font);
void createHardwareInfoHolders(HWND, SystemInfo*);
void populateInfoHolders(SystemInfo *machine, HWND);
void createIPToggleControl(HWND parent);
void createIPToggleControl(HWND, int, int);
void loadImages(void);
void toggleIpAddress(HWND, SystemInfo*);
void updateNetworkAdaptersView(SystemInfo*);
#endif
3 changes: 1 addition & 2 deletions SystemInfo/saveSpecs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ bool saveSpecs::saveAsXML(HWND hwnd, SystemInfo *info) {
xmlOutFile << _T("\">\n\t\t");

writeToFile(xmlOutFile, info, x, WRITE_OUT_TYPE::FILE_XML);



xmlOutFile << L"\t</item>\n";
}
xmlOutFile<<L"</hardwareinfo>\n";
Expand Down
2 changes: 0 additions & 2 deletions SystemInfo/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ void openFileDiag(HWND mainWindow,
TCHAR szFile[MAX_PATH];
ZeroMemory(&fileName, sizeof(fileName));
fileName.lStructSize = sizeof(fileName);
//fileName.lpstrFile = szFile;
//fileName.lpstrFile[0] = '\0';
fileName.hwndOwner = mainWindow;
fileName.nMaxFile = sizeof(szFile);

Expand Down
5 changes: 5 additions & 0 deletions SystemInfo/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ enum class FILE_IO_OPERATION {
SAVE_AS,
OPEN
};
static wstring ipToggleText[]{
L"Hide IP",
L"Show IP"
};
static wstring writeOutPrefix[] {
L"",
L"",
Expand Down Expand Up @@ -44,6 +48,7 @@ enum class FILE_EXTENSION {
BIN,
PNG
};

static std::wstring storageMediumManufacturers[20]
{
L"Western Digital",
Expand Down

0 comments on commit dca8693

Please sign in to comment.