mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Cosmetic changes to code.
This commit is contained in:
parent
5882f12c49
commit
a92bdd9b18
@ -94,22 +94,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
return RetSuccess;
|
||||
}
|
||||
|
||||
if(!hPrevInstance)
|
||||
if (!hPrevInstance)
|
||||
{
|
||||
if (!InitApplication(hInstance, WinClass)) return RetError;
|
||||
}
|
||||
|
||||
hWnd=InitInstance(hInstance, WinClass, WinName);
|
||||
if(!hWnd) return RetError;
|
||||
if (!hWnd) return RetError;
|
||||
|
||||
// Remove quotes from the commandline
|
||||
WCHAR Path[MAX_PATH+1] = {0};
|
||||
if(lpCmdLine)
|
||||
if (lpCmdLine)
|
||||
{
|
||||
size_t Pos = 0;
|
||||
for(size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i)
|
||||
for (size_t i = 0, len = wcslen(lpCmdLine); i <= len && Pos < MAX_PATH; ++i)
|
||||
{
|
||||
if(lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
|
||||
if (lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
|
||||
// Check that the DLL is available
|
||||
HMODULE module = GetModuleHandle(L"Rainmeter.dll");
|
||||
if(module == NULL)
|
||||
if (module == NULL)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
DestroyWindow(hWnd);
|
||||
|
@ -127,7 +127,7 @@ void UpdateAboutDialog()
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
if (_wcsicmp(selectedItemName, (*iter).first.c_str()) == 0)
|
||||
{
|
||||
@ -200,7 +200,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
if (current == selected)
|
||||
{
|
||||
@ -213,7 +213,7 @@ void UpdateAboutStatistics(LPCTSTR entryName)
|
||||
|
||||
int index = 0;
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
const WCHAR* name = (*i)->GetName();
|
||||
const WCHAR* val = (*i)->GetStats();
|
||||
@ -477,7 +477,7 @@ BOOL OnInitAboutDialog(HWND window)
|
||||
size_t namelength = skinName.length();
|
||||
|
||||
int currwidth = (int)SendMessage(widget, LB_GETHORIZONTALEXTENT, NULL, NULL);
|
||||
if(6 * (int)namelength > currwidth)
|
||||
if (6 * (int)namelength > currwidth)
|
||||
{
|
||||
SendMessage(widget, LB_SETHORIZONTALEXTENT, 6 * namelength, NULL);
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
|
||||
return (m_LastDefaultUsed) ? defValue : ParseDouble(result, defValue);
|
||||
}
|
||||
|
||||
// Returns an int if the formula was read successfully, -1 for failure.
|
||||
// Returns 1 if the formula was read successfully, -1 for failure.
|
||||
// Pass a pointer to a double.
|
||||
int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
|
||||
{
|
||||
@ -822,9 +822,9 @@ std::vector<std::wstring> CConfigParser::Tokenize(const std::wstring& str, const
|
||||
|
||||
while (std::wstring::npos != pos || std::wstring::npos != lastPos)
|
||||
{
|
||||
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
|
||||
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
|
||||
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
|
||||
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
|
||||
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
|
||||
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
|
||||
}
|
||||
|
||||
return tokens;
|
||||
@ -886,7 +886,7 @@ Color CConfigParser::ParseColor(LPCTSTR string)
|
||||
{
|
||||
int R, G, B, A;
|
||||
|
||||
if(wcschr(string, L',') != NULL)
|
||||
if (wcschr(string, L',') != NULL)
|
||||
{
|
||||
WCHAR* parseSz = _wcsdup(string);
|
||||
WCHAR* token;
|
||||
@ -1067,7 +1067,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
WCHAR* epos = NULL;
|
||||
|
||||
// Get all the sections
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
items[0] = 0;
|
||||
int res = GetPrivateProfileString( NULL, NULL, NULL, items, size, iniRead.c_str());
|
||||
@ -1117,7 +1117,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
std::list<std::wstring>::const_iterator iter = sections.begin();
|
||||
for ( ; iter != sections.end(); ++iter)
|
||||
{
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
items[0] = 0;
|
||||
int res = GetPrivateProfileString((*iter).c_str(), NULL, NULL, items, size, iniRead.c_str());
|
||||
@ -1139,7 +1139,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
{
|
||||
std::wstring strKey = pos;
|
||||
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
int res = GetPrivateProfileString((*iter).c_str(), strKey.c_str(), L"", buffer, bufferSize, iniRead.c_str());
|
||||
|
@ -281,7 +281,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||
PSID AdministratorsGroup;
|
||||
// Initialize SID.
|
||||
if( !AllocateAndInitializeSid( &NtAuthority,
|
||||
if (!AllocateAndInitializeSid( &NtAuthority,
|
||||
2,
|
||||
SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS,
|
||||
@ -294,7 +294,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
else
|
||||
{
|
||||
// Check whether the token is present in admin group.
|
||||
if( !CheckTokenMembership( NULL,
|
||||
if (!CheckTokenMembership( NULL,
|
||||
AdministratorsGroup,
|
||||
&IsInAdminGroup ))
|
||||
{
|
||||
@ -318,7 +318,7 @@ HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpLSExecute)
|
||||
if (fpLSExecute)
|
||||
{
|
||||
std::string asc = ConvertToAscii(szCommand);
|
||||
return fpLSExecute(Owner, asc.c_str(), nShowCmd);
|
||||
@ -612,7 +612,7 @@ void LogWithArgs(int nLevel, const WCHAR* format, ... )
|
||||
{
|
||||
WCHAR* buffer = new WCHAR[4096];
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
va_start( args, format );
|
||||
|
||||
_invalid_parameter_handler oldHandler = _set_invalid_parameter_handler(RmNullCRTInvalidParameterHandler);
|
||||
_CrtSetReportMode(_CRT_ASSERT, 0);
|
||||
|
@ -355,7 +355,7 @@ bool CMeasure::PreUpdate()
|
||||
|
||||
// If we're logging the maximum value of the measure, check if
|
||||
// the new value is greater than the old one, and update if necessary.
|
||||
if(m_LogMaxValue)
|
||||
if (m_LogMaxValue)
|
||||
{
|
||||
if (m_MedianMaxValues.empty())
|
||||
{
|
||||
@ -382,11 +382,11 @@ bool CMeasure::PreUpdate()
|
||||
if (m_MeterWindow)
|
||||
{
|
||||
// Check the IfEqualValue
|
||||
if(!m_IfEqualAction.empty())
|
||||
if (!m_IfEqualAction.empty())
|
||||
{
|
||||
if((int)m_Value == (int)m_IfEqualValue)
|
||||
if ((int)m_Value == (int)m_IfEqualValue)
|
||||
{
|
||||
if(!m_IfEqualCommited)
|
||||
if (!m_IfEqualCommited)
|
||||
{
|
||||
m_IfEqualCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow);
|
||||
@ -399,11 +399,11 @@ bool CMeasure::PreUpdate()
|
||||
}
|
||||
|
||||
// Check the IfAboveValue
|
||||
if(!m_IfAboveAction.empty())
|
||||
if (!m_IfAboveAction.empty())
|
||||
{
|
||||
if(m_Value > m_IfAboveValue)
|
||||
if (m_Value > m_IfAboveValue)
|
||||
{
|
||||
if(!m_IfAboveCommited)
|
||||
if (!m_IfAboveCommited)
|
||||
{
|
||||
m_IfAboveCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow);
|
||||
@ -416,11 +416,11 @@ bool CMeasure::PreUpdate()
|
||||
}
|
||||
|
||||
// Check the IfBelowValue
|
||||
if(!m_IfBelowAction.empty())
|
||||
if (!m_IfBelowAction.empty())
|
||||
{
|
||||
if(m_Value < m_IfBelowValue)
|
||||
if (m_Value < m_IfBelowValue)
|
||||
{
|
||||
if(!m_IfBelowCommited)
|
||||
if (!m_IfBelowCommited)
|
||||
{
|
||||
m_IfBelowCommited = true; // To avoid crashing by !RainmeterUpdate due to infinite loop
|
||||
Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow);
|
||||
@ -540,7 +540,7 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
|
||||
static WCHAR buffer[MAX_LINE_LENGTH];
|
||||
WCHAR format[32];
|
||||
|
||||
if(percentual)
|
||||
if (percentual)
|
||||
{
|
||||
double val = 100.0 * GetRelativeValue();
|
||||
|
||||
@ -554,7 +554,7 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
|
||||
_snwprintf_s(buffer, _TRUNCATE, format, val);
|
||||
}
|
||||
}
|
||||
else if(autoScale != AUTOSCALE_OFF)
|
||||
else if (autoScale != AUTOSCALE_OFF)
|
||||
{
|
||||
GetScaledValue(autoScale, decimals, GetValue(), buffer, _countof(buffer));
|
||||
}
|
||||
@ -562,7 +562,7 @@ const WCHAR* CMeasure::GetStringValue(AUTOSCALE autoScale, double scale, int dec
|
||||
{
|
||||
double val = GetValue() / scale;
|
||||
|
||||
if(decimals == 0)
|
||||
if (decimals == 0)
|
||||
{
|
||||
val += (val >= 0) ? 0.5 : -0.5;
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%lli", (LONGLONG)val);
|
||||
@ -592,7 +592,7 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
|
||||
WCHAR format[32];
|
||||
double value = 0;
|
||||
|
||||
if(decimals == 0)
|
||||
if (decimals == 0)
|
||||
{
|
||||
wcsncpy_s(format, L"%.0f", _TRUNCATE);
|
||||
}
|
||||
@ -603,22 +603,22 @@ void CMeasure::GetScaledValue(AUTOSCALE autoScale, int decimals, double theValue
|
||||
|
||||
int index = (autoScale == AUTOSCALE_1000 || autoScale == AUTOSCALE_1000K) ? AUTOSCALE_INDEX_1000 : AUTOSCALE_INDEX_1024;
|
||||
|
||||
if(theValue > (g_TblScale[index][0] * 0.99))
|
||||
if (theValue > (g_TblScale[index][0] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" T", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][0];
|
||||
}
|
||||
else if(theValue > (g_TblScale[index][1] * 0.99))
|
||||
else if (theValue > (g_TblScale[index][1] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" G", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][1];
|
||||
}
|
||||
else if(theValue > (g_TblScale[index][2] * 0.99))
|
||||
else if (theValue > (g_TblScale[index][2] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" M", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][2];
|
||||
}
|
||||
else if(autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99))
|
||||
else if (autoScale == AUTOSCALE_1024K || autoScale == AUTOSCALE_1000K || theValue > (g_TblScale[index][3] * 0.99))
|
||||
{
|
||||
wcsncat_s(format, L" k", _TRUNCATE);
|
||||
value = theValue / g_TblScale[index][3];
|
||||
@ -657,63 +657,63 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, cons
|
||||
{
|
||||
// Comparison is caseinsensitive
|
||||
|
||||
if(*measure == L'\0')
|
||||
if (*measure == L'\0')
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if(_wcsicmp(L"CPU", measure) == 0)
|
||||
else if (_wcsicmp(L"CPU", measure) == 0)
|
||||
{
|
||||
return new CMeasureCPU(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Memory", measure) == 0)
|
||||
else if (_wcsicmp(L"Memory", measure) == 0)
|
||||
{
|
||||
return new CMeasureMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetIn", measure) == 0)
|
||||
else if (_wcsicmp(L"NetIn", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetIn(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetOut", measure) == 0)
|
||||
else if (_wcsicmp(L"NetOut", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetOut(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"NetTotal", measure) == 0)
|
||||
else if (_wcsicmp(L"NetTotal", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetTotal(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"PhysicalMemory", measure) == 0)
|
||||
else if (_wcsicmp(L"PhysicalMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasurePhysicalMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"SwapMemory", measure) == 0)
|
||||
else if (_wcsicmp(L"SwapMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasureVirtualMemory(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"FreeDiskSpace", measure) == 0)
|
||||
else if (_wcsicmp(L"FreeDiskSpace", measure) == 0)
|
||||
{
|
||||
return new CMeasureDiskSpace(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Uptime", measure) == 0)
|
||||
else if (_wcsicmp(L"Uptime", measure) == 0)
|
||||
{
|
||||
return new CMeasureUptime(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Time", measure) == 0)
|
||||
else if (_wcsicmp(L"Time", measure) == 0)
|
||||
{
|
||||
return new CMeasureTime(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Plugin", measure) == 0)
|
||||
else if (_wcsicmp(L"Plugin", measure) == 0)
|
||||
{
|
||||
return new CMeasurePlugin(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Registry", measure) == 0)
|
||||
else if (_wcsicmp(L"Registry", measure) == 0)
|
||||
{
|
||||
return new CMeasureRegistry(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"Calc", measure) == 0)
|
||||
else if (_wcsicmp(L"Calc", measure) == 0)
|
||||
{
|
||||
return new CMeasureCalc(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"script", measure) == 0)
|
||||
else if (_wcsicmp(L"script", measure) == 0)
|
||||
{
|
||||
return new CMeasureScript(meterWindow, name);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow, const WCHAR* name) : CMeas
|
||||
m_HighBound(100),
|
||||
m_UpdateRandom(false)
|
||||
{
|
||||
if(!c_RandSeeded)
|
||||
if (!c_RandSeeded)
|
||||
{
|
||||
c_RandSeeded = true;
|
||||
srand((unsigned)time(0));
|
||||
@ -103,7 +103,7 @@ void CMeasureCalc::UpdateVariableMap(CMeterWindow& meterWindow)
|
||||
const std::list<CMeasure*>& measures = meterWindow.GetMeasures();
|
||||
|
||||
std::list<CMeasure*>::const_iterator iter = measures.begin();
|
||||
for( ; iter != measures.end(); ++iter)
|
||||
for ( ; iter != measures.end(); ++iter)
|
||||
{
|
||||
const char* name = (*iter)->GetANSIName();
|
||||
double val = (*iter)->GetValue();
|
||||
|
@ -394,7 +394,7 @@ ULONG64 CMeasureNet::GetNetStatsValue(NET net)
|
||||
if (m_Interface == 0)
|
||||
{
|
||||
// Get all interfaces
|
||||
for(size_t i = 0; i < statsSize; ++i)
|
||||
for (size_t i = 0; i < statsSize; ++i)
|
||||
{
|
||||
// Ignore the loopback and filter interfaces
|
||||
if (c_NumOfTables == statsSize)
|
||||
|
@ -51,7 +51,7 @@ bool CMeasureNetIn::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ bool CMeasureNetOut::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ bool CMeasureNetTotal::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
if (c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ CMeasurePlugin::~CMeasurePlugin()
|
||||
{
|
||||
if (m_Plugin)
|
||||
{
|
||||
if(FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
|
||||
if (FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
|
||||
FreeLibrary(m_Plugin);
|
||||
}
|
||||
}
|
||||
@ -78,12 +78,12 @@ bool CMeasurePlugin::Update()
|
||||
}
|
||||
SetCurrentDirectory(dir.c_str());
|
||||
|
||||
if(UpdateFunc)
|
||||
if (UpdateFunc)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc(m_ID);
|
||||
}
|
||||
else if(UpdateFunc2)
|
||||
else if (UpdateFunc2)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc2(m_ID);
|
||||
@ -128,7 +128,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
DWORD err = 0;
|
||||
m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err);
|
||||
|
||||
if(m_Plugin == NULL)
|
||||
if (m_Plugin == NULL)
|
||||
{
|
||||
if (CRainmeter::GetDebug())
|
||||
{
|
||||
@ -179,7 +179,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
// Initialize the plugin
|
||||
m_ID = id++;
|
||||
if(InitializeFunc)
|
||||
if (InitializeFunc)
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, buffer);
|
||||
@ -206,7 +206,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
}
|
||||
|
||||
if(m_MaxValue == 0)
|
||||
if (m_MaxValue == 0)
|
||||
{
|
||||
m_MaxValue = 1;
|
||||
m_LogMaxValue = true;
|
||||
@ -221,7 +221,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
*/
|
||||
const WCHAR* CMeasurePlugin::GetStringValue(AUTOSCALE autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if(GetStringFunc)
|
||||
if (GetStringFunc)
|
||||
{
|
||||
const WCHAR* ret = GetStringFunc(m_ID, 0);
|
||||
if (ret) return CheckSubstitute(ret);
|
||||
|
@ -42,7 +42,7 @@ CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow, const WCHAR* name)
|
||||
*/
|
||||
CMeasureRegistry::~CMeasureRegistry()
|
||||
{
|
||||
if(m_RegKey) RegCloseKey(m_RegKey);
|
||||
if (m_RegKey) RegCloseKey(m_RegKey);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -55,13 +55,13 @@ bool CMeasureRegistry::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if(m_RegKey != NULL)
|
||||
if (m_RegKey != NULL)
|
||||
{
|
||||
DWORD size = 4096;
|
||||
WCHAR* data = new WCHAR[size];
|
||||
DWORD type = 0;
|
||||
|
||||
if(RegQueryValueEx(m_RegKey,
|
||||
if (RegQueryValueEx(m_RegKey,
|
||||
m_RegValueName.c_str(),
|
||||
NULL,
|
||||
(LPDWORD)&type,
|
||||
@ -120,31 +120,31 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
|
||||
if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_CONFIG;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_USER;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
|
||||
{
|
||||
m_HKey = HKEY_LOCAL_MACHINE;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_PERFORMANCE_DATA;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
|
||||
else if (_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_DYN_DATA;
|
||||
}
|
||||
@ -167,7 +167,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
// Try to open the key
|
||||
if(m_RegKey) RegCloseKey(m_RegKey);
|
||||
if (m_RegKey) RegCloseKey(m_RegKey);
|
||||
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ static void stackDump(lua_State *L)
|
||||
{
|
||||
int i = lua_gettop(L);
|
||||
LuaManager::LuaLog(LOG_DEBUG, " ---------------- Stack Dump ----------------" );
|
||||
while(i)
|
||||
while (i)
|
||||
{
|
||||
int t = lua_type(L, i);
|
||||
switch (t)
|
||||
@ -194,7 +194,7 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
lua_pushnil(L);
|
||||
|
||||
while(lua_next(L, -2))
|
||||
while (lua_next(L, -2))
|
||||
{
|
||||
lua_pop(L, 1);
|
||||
|
||||
|
@ -453,9 +453,9 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
|
||||
// Go through the list and check it there is a measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
|
||||
{
|
||||
m_Measure = (*i);
|
||||
return;
|
||||
@ -479,39 +479,39 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
*/
|
||||
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHAR* name)
|
||||
{
|
||||
if(_wcsicmp(L"HISTOGRAM", meter) == 0)
|
||||
if (_wcsicmp(L"HISTOGRAM", meter) == 0)
|
||||
{
|
||||
return new CMeterHistogram(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"STRING", meter) == 0)
|
||||
else if (_wcsicmp(L"STRING", meter) == 0)
|
||||
{
|
||||
return new CMeterString(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BAR", meter) == 0)
|
||||
else if (_wcsicmp(L"BAR", meter) == 0)
|
||||
{
|
||||
return new CMeterBar(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BITMAP", meter) == 0)
|
||||
else if (_wcsicmp(L"BITMAP", meter) == 0)
|
||||
{
|
||||
return new CMeterBitmap(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"IMAGE", meter) == 0)
|
||||
else if (_wcsicmp(L"IMAGE", meter) == 0)
|
||||
{
|
||||
return new CMeterImage(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"LINE", meter) == 0)
|
||||
else if (_wcsicmp(L"LINE", meter) == 0)
|
||||
{
|
||||
return new CMeterLine(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"ROUNDLINE", meter) == 0)
|
||||
else if (_wcsicmp(L"ROUNDLINE", meter) == 0)
|
||||
{
|
||||
return new CMeterRoundLine(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"ROTATOR", meter) == 0)
|
||||
else if (_wcsicmp(L"ROTATOR", meter) == 0)
|
||||
{
|
||||
return new CMeterRotator(meterWindow, name);
|
||||
}
|
||||
else if(_wcsicmp(L"BUTTON", meter) == 0)
|
||||
else if (_wcsicmp(L"BUTTON", meter) == 0)
|
||||
{
|
||||
return new CMeterButton(meterWindow, name);
|
||||
}
|
||||
@ -566,7 +566,7 @@ void CMeter::SetAllMeasures(const std::vector<CMeasure*>& measures)
|
||||
m_AllMeasures.push_back(m_Measure);
|
||||
|
||||
std::vector<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
m_AllMeasures.push_back(*i);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ void CMeterBar::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -120,11 +120,11 @@ void CMeterBar::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_Flip = parser.ReadInt(section, L"Flip", 0) == 1;
|
||||
|
||||
const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
|
||||
if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
if (_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = VERTICAL;
|
||||
}
|
||||
else if(_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
|
||||
else if (_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = HORIZONTAL;
|
||||
}
|
||||
@ -179,14 +179,14 @@ bool CMeterBar::Update()
|
||||
*/
|
||||
bool CMeterBar::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
Bitmap* drawBitmap = m_Image.GetImage();
|
||||
|
||||
if(m_Orientation == VERTICAL)
|
||||
if (m_Orientation == VERTICAL)
|
||||
{
|
||||
int barSize = m_H - 2 * m_Border;
|
||||
int size = (int)(barSize * m_Value);
|
||||
|
@ -69,7 +69,7 @@ void CMeterBitmap::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -80,7 +80,7 @@ void CMeterBitmap::Initialize()
|
||||
m_W = bitmap->GetWidth();
|
||||
m_H = bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
if (m_H > m_W)
|
||||
{
|
||||
m_H = m_H / m_FrameCount;
|
||||
}
|
||||
@ -195,15 +195,15 @@ void CMeterBitmap::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
|
||||
|
||||
const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
if (_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
@ -290,11 +290,11 @@ bool CMeterBitmap::HasActiveTransition()
|
||||
*/
|
||||
bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
int newY, newX;
|
||||
|
||||
if(m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
|
||||
if (m_FrameCount == 0 || !m_Image.IsLoaded()) return false; // Unable to continue
|
||||
|
||||
Bitmap* bitmap = m_Image.GetImage();
|
||||
|
||||
@ -383,7 +383,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
|
||||
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = m_H * frame;
|
||||
@ -449,7 +449,7 @@ bool CMeterBitmap::Draw(Graphics& graphics)
|
||||
|
||||
// LogWithArgs(LOG_DEBUG, L"[%u] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = frame * m_H;
|
||||
|
@ -83,7 +83,7 @@ void CMeterButton::Initialize()
|
||||
}
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
|
||||
@ -94,7 +94,7 @@ void CMeterButton::Initialize()
|
||||
m_W = bitmap->GetWidth();
|
||||
m_H = bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
if (m_H > m_W)
|
||||
{
|
||||
m_H = m_H / BUTTON_FRAMES;
|
||||
}
|
||||
@ -112,7 +112,7 @@ void CMeterButton::Initialize()
|
||||
Graphics graphics(&bitmapPart);
|
||||
Rect r(0, 0, m_W, m_H);
|
||||
|
||||
if(bitmap->GetHeight() > bitmap->GetWidth())
|
||||
if (bitmap->GetHeight() > bitmap->GetWidth())
|
||||
{
|
||||
graphics.DrawImage(bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel);
|
||||
}
|
||||
@ -198,7 +198,7 @@ bool CMeterButton::Update()
|
||||
*/
|
||||
bool CMeterButton::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Bitmaps[m_State] == NULL) return false; // Unable to continue
|
||||
|
||||
|
@ -109,7 +109,7 @@ void CMeterHistogram::Initialize()
|
||||
// A sanity check
|
||||
if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty()))
|
||||
{
|
||||
Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!");
|
||||
Log(LOG_WARNING, L"You need to define SecondaryImage and BothImage also!");
|
||||
|
||||
m_PrimaryImage.DisposeImage();
|
||||
m_SecondaryImage.DisposeImage();
|
||||
@ -385,7 +385,7 @@ bool CMeterHistogram::Update()
|
||||
*/
|
||||
bool CMeterHistogram::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics) ||
|
||||
if (!CMeter::Draw(graphics) ||
|
||||
(m_Measure && !m_PrimaryValues) ||
|
||||
(m_SecondaryMeasure && !m_SecondaryValues)) return false;
|
||||
|
||||
@ -517,13 +517,13 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
|
||||
if(!m_SecondaryMeasureName.empty())
|
||||
if (!m_SecondaryMeasureName.empty())
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||
{
|
||||
m_SecondaryMeasure = (*i);
|
||||
CMeter::SetAllMeasures(m_SecondaryMeasure);
|
||||
@ -535,6 +535,6 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
error += L"] cannot be bound with [";
|
||||
error += m_SecondaryMeasureName;
|
||||
error += L"]!";
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ bool CMeterImage::Update()
|
||||
*/
|
||||
bool CMeterImage::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Image.IsLoaded())
|
||||
{
|
||||
@ -366,9 +366,9 @@ void CMeterImage::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measures for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
|
@ -208,7 +208,7 @@ bool CMeterLine::Update()
|
||||
*/
|
||||
bool CMeterLine::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics) || m_W == 0) return false;
|
||||
if (!CMeter::Draw(graphics) || m_W == 0) return false;
|
||||
|
||||
double maxValue = 0.0;
|
||||
int counter = 0;
|
||||
@ -277,7 +277,7 @@ bool CMeterLine::Draw(Graphics& graphics)
|
||||
|
||||
// Check the highest power of 2 that fits in maxLines
|
||||
int power = 2;
|
||||
while(power < maxLines)
|
||||
while (power < maxLines)
|
||||
{
|
||||
power *= 2;
|
||||
}
|
||||
@ -362,9 +362,9 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
@ -377,7 +377,7 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
error += L"] cannot be bound with [";
|
||||
error += (*j);
|
||||
error += L"]!";
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
throw CError(error, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
CMeter::SetAllMeasures(m_Measures);
|
||||
|
@ -65,7 +65,7 @@ void CMeterRotator::Initialize()
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
m_Image.LoadImage(m_ImageName, m_NeedsReload);
|
||||
}
|
||||
@ -157,7 +157,7 @@ bool CMeterRotator::Update()
|
||||
*/
|
||||
bool CMeterRotator::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
if (m_Image.IsLoaded())
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ void CMeterRoundLine::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
|
||||
m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0);
|
||||
m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0);
|
||||
m_LineStart = parser.ReadFormula(section, L"LineStart", -1.0);
|
||||
m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
|
||||
m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
||||
@ -123,7 +123,7 @@ bool CMeterRoundLine::Update()
|
||||
*/
|
||||
bool CMeterRoundLine::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
// Calculate the center of for the line
|
||||
int x = GetX();
|
||||
|
@ -259,7 +259,7 @@ void CMeterString::Initialize()
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style);
|
||||
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif (), size, style);
|
||||
}
|
||||
|
||||
Status status = m_Font->GetLastStatus();
|
||||
@ -361,15 +361,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_Scale = wcstod(scale.c_str(), NULL);
|
||||
|
||||
const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT");
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
if (_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
else if (_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
@ -383,19 +383,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE");
|
||||
if(_wcsicmp(stringCase.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(stringCase.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_NONE;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"UPPER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"UPPER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_UPPER;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"LOWER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"LOWER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_LOWER;
|
||||
}
|
||||
else if(_wcsicmp(stringCase.c_str(), L"PROPER") == 0)
|
||||
else if (_wcsicmp(stringCase.c_str(), L"PROPER") == 0)
|
||||
{
|
||||
m_textCase = TEXTCASE_PROPER;
|
||||
}
|
||||
@ -409,19 +409,19 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL");
|
||||
if(_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
if (_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
{
|
||||
m_Style = NORMAL;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLD") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"BOLD") == 0)
|
||||
{
|
||||
m_Style = BOLD;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"ITALIC") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"ITALIC") == 0)
|
||||
{
|
||||
m_Style = ITALIC;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
|
||||
else if (_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
|
||||
{
|
||||
m_Style = BOLDITALIC;
|
||||
}
|
||||
@ -435,15 +435,15 @@ void CMeterString::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
}
|
||||
|
||||
const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE");
|
||||
if(_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(effect.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_NONE;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"SHADOW") == 0)
|
||||
else if (_wcsicmp(effect.c_str(), L"SHADOW") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_SHADOW;
|
||||
}
|
||||
else if(_wcsicmp(effect.c_str(), L"BORDER") == 0)
|
||||
else if (_wcsicmp(effect.c_str(), L"BORDER") == 0)
|
||||
{
|
||||
m_Effect = EFFECT_BORDER;
|
||||
}
|
||||
@ -556,7 +556,7 @@ bool CMeterString::Update()
|
||||
*/
|
||||
bool CMeterString::Draw(Graphics& graphics)
|
||||
{
|
||||
if(!CMeter::Draw(graphics)) return false;
|
||||
if (!CMeter::Draw(graphics)) return false;
|
||||
|
||||
return DrawString(graphics, NULL);
|
||||
}
|
||||
@ -680,9 +680,9 @@ void CMeterString::BindMeasure(const std::list<CMeasure*>& measures)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measures for us
|
||||
std::list<CMeasure*>::const_iterator i = measures.begin();
|
||||
for( ; i != measures.end(); ++i)
|
||||
for ( ; i != measures.end(); ++i)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
if (_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
|
@ -147,25 +147,25 @@ CMeterWindow::~CMeterWindow()
|
||||
|
||||
// Destroy the meters
|
||||
std::list<CMeter*>::iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
delete (*j);
|
||||
}
|
||||
|
||||
// Destroy the measures
|
||||
std::list<CMeasure*>::iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
|
||||
if(m_Background) delete m_Background;
|
||||
if(m_DoubleBuffer) delete m_DoubleBuffer;
|
||||
if(m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
|
||||
if (m_Background) delete m_Background;
|
||||
if (m_DoubleBuffer) delete m_DoubleBuffer;
|
||||
if (m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
|
||||
|
||||
if(m_Window) DestroyWindow(m_Window);
|
||||
if (m_Window) DestroyWindow(m_Window);
|
||||
|
||||
if(m_FontCollection)
|
||||
if (m_FontCollection)
|
||||
{
|
||||
CMeterString::FreeFontCache(m_FontCollection);
|
||||
delete m_FontCollection;
|
||||
@ -205,7 +205,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
|
||||
wc.hCursor = NULL; // The cursor should be controlled by using SetCursor() when needed.
|
||||
wc.lpszClassName = METERWINDOW_CLASS_NAME;
|
||||
|
||||
if(!RegisterClassEx(&wc))
|
||||
if (!RegisterClassEx(&wc))
|
||||
{
|
||||
DWORD err = GetLastError();
|
||||
|
||||
@ -228,7 +228,7 @@ int CMeterWindow::Initialize(CRainmeter& Rainmeter)
|
||||
m_Rainmeter->GetInstance(),
|
||||
this);
|
||||
|
||||
if(m_Window == NULL)
|
||||
if (m_Window == NULL)
|
||||
{
|
||||
throw CError(CError::ERROR_CREATE_WINDOW, __LINE__, __FILE__);
|
||||
}
|
||||
@ -310,7 +310,7 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
|
||||
m_Refreshing = true;
|
||||
|
||||
if(!init)
|
||||
if (!init)
|
||||
{
|
||||
// First destroy everything
|
||||
// WriteConfig(); //Not clear why this is needed and it messes up resolution changes
|
||||
@ -325,7 +325,7 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
SetMouseLeaveEvent(true);
|
||||
|
||||
std::list<CMeasure*>::iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
delete (*i);
|
||||
}
|
||||
@ -333,13 +333,13 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
m_ScriptMeasures.clear();
|
||||
|
||||
std::list<CMeter*>::iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
delete (*j);
|
||||
}
|
||||
m_Meters.clear();
|
||||
|
||||
if(m_Background) delete m_Background;
|
||||
if (m_Background) delete m_Background;
|
||||
m_Background = NULL;
|
||||
|
||||
m_BackgroundSize.cx = m_BackgroundSize.cy = 0;
|
||||
@ -393,13 +393,13 @@ void CMeterWindow::Refresh(bool init, bool all)
|
||||
// Start the timers
|
||||
if (m_WindowUpdate >= 0)
|
||||
{
|
||||
if(0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL))
|
||||
if (0 == SetTimer(m_Window, METERTIMER, m_WindowUpdate, NULL))
|
||||
{
|
||||
throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
if(0 == SetTimer(m_Window, MOUSETIMER, 500, NULL)) // Mouse position is checked twice per sec
|
||||
if (0 == SetTimer(m_Window, MOUSETIMER, 500, NULL)) // Mouse position is checked twice per sec
|
||||
{
|
||||
throw CError(L"Unable to create a timer!", __LINE__, __FILE__);
|
||||
}
|
||||
@ -506,7 +506,7 @@ void CMeterWindow::MapCoordsToScreen(int& x, int& y, int w, int h)
|
||||
|
||||
hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
|
||||
|
||||
if(hMonitor != NULL)
|
||||
if (hMonitor != NULL)
|
||||
{
|
||||
mi.cbSize = sizeof(mi);
|
||||
GetMonitorInfo(hMonitor, &mi);
|
||||
@ -556,7 +556,7 @@ void CMeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
|
||||
{
|
||||
#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)
|
||||
|
||||
if(!m_ChildWindow)
|
||||
if (!m_ChildWindow)
|
||||
{
|
||||
HWND winPos = HWND_NOTOPMOST;
|
||||
m_WindowZPosition = zPos;
|
||||
@ -927,7 +927,7 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
|
||||
int result = m_Parser.ReadFormula(strValue, &value);
|
||||
|
||||
// Formula read fine
|
||||
if(result != -1)
|
||||
if (result != -1)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"%f", value);
|
||||
@ -972,7 +972,7 @@ void CMeterWindow::ShowMeter(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (CompareName((*j), name, group))
|
||||
{
|
||||
@ -996,7 +996,7 @@ void CMeterWindow::HideMeter(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (CompareName((*j), name, group))
|
||||
{
|
||||
@ -1020,7 +1020,7 @@ void CMeterWindow::ToggleMeter(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (CompareName((*j), name, group))
|
||||
{
|
||||
@ -1051,7 +1051,7 @@ void CMeterWindow::MoveMeter(int x, int y, const WCHAR* name)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (CompareName((*j), name, false))
|
||||
{
|
||||
@ -1078,7 +1078,7 @@ void CMeterWindow::UpdateMeter(const WCHAR* name, bool group)
|
||||
bool bActiveTransition = false;
|
||||
bool bContinue = true;
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (bContinue && CompareName((*j), name, group))
|
||||
{
|
||||
@ -1118,7 +1118,7 @@ void CMeterWindow::EnableMeasure(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
if (CompareName((*i), name, group))
|
||||
{
|
||||
@ -1141,7 +1141,7 @@ void CMeterWindow::DisableMeasure(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
if (CompareName((*i), name, group))
|
||||
{
|
||||
@ -1164,7 +1164,7 @@ void CMeterWindow::ToggleMeasure(const WCHAR* name, bool group)
|
||||
if (name == NULL || *name == 0) return;
|
||||
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
if (CompareName((*i), name, group))
|
||||
{
|
||||
@ -1201,7 +1201,7 @@ void CMeterWindow::UpdateMeasure(const WCHAR* name, bool group)
|
||||
|
||||
bool bNetStats = m_HasNetMeasures;
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
if (CompareName((*i), name, group))
|
||||
{
|
||||
@ -1420,7 +1420,7 @@ void CMeterWindow::WindowToScreen()
|
||||
{
|
||||
pixel = screeny + pixel;
|
||||
}
|
||||
m_ScreenY = pixel - m_AnchorScreenY;
|
||||
m_ScreenY = pixel - m_AnchorScreenY;
|
||||
}
|
||||
|
||||
/* ScreenToWindow
|
||||
@ -1689,10 +1689,10 @@ void CMeterWindow::WriteConfig()
|
||||
const std::wstring& iniFile = m_Rainmeter->GetIniFile();
|
||||
const WCHAR* section = m_SkinName.c_str();
|
||||
|
||||
if(!iniFile.empty())
|
||||
if (!iniFile.empty())
|
||||
{
|
||||
// If position needs to be save, do so.
|
||||
if(m_SavePosition)
|
||||
if (m_SavePosition)
|
||||
{
|
||||
ScreenToWindow();
|
||||
WritePrivateProfileString(section, L"WindowX", m_WindowX.c_str(), iniFile.c_str());
|
||||
@ -1835,7 +1835,7 @@ bool CMeterWindow::ReadSkin()
|
||||
// Checking for localfonts
|
||||
std::wstring localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L"");
|
||||
// If there is a local font we want to load it
|
||||
if(!localFont.empty())
|
||||
if (!localFont.empty())
|
||||
{
|
||||
m_FontCollection = new PrivateFontCollection();
|
||||
|
||||
@ -1850,7 +1850,7 @@ bool CMeterWindow::ReadSkin()
|
||||
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||
|
||||
// It wasn't found in the fonts folder, check the local folder
|
||||
if(nResults != Ok)
|
||||
if (nResults != Ok)
|
||||
{
|
||||
szFontFile = m_SkinPath; // Get the local path
|
||||
szFontFile += m_SkinName;
|
||||
@ -1859,12 +1859,12 @@ bool CMeterWindow::ReadSkin()
|
||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||
|
||||
// The font wasn't found, check full path.
|
||||
if(nResults != Ok)
|
||||
if (nResults != Ok)
|
||||
{
|
||||
szFontFile = localFont;
|
||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||
|
||||
if(nResults != Ok)
|
||||
if (nResults != Ok)
|
||||
{
|
||||
std::wstring error = L"Unable to load font file: " + localFont;
|
||||
Log(LOG_ERROR, error.c_str());
|
||||
@ -1893,7 +1893,7 @@ bool CMeterWindow::ReadSkin()
|
||||
{
|
||||
const std::wstring& strSection = arraySections[i];
|
||||
|
||||
if(_wcsicmp(L"Rainmeter", strSection.c_str()) != 0 &&
|
||||
if (_wcsicmp(L"Rainmeter", strSection.c_str()) != 0 &&
|
||||
_wcsicmp(L"Variables", strSection.c_str()) != 0 &&
|
||||
_wcsicmp(L"Metadata", strSection.c_str()) != 0)
|
||||
{
|
||||
@ -1921,7 +1921,7 @@ bool CMeterWindow::ReadSkin()
|
||||
}
|
||||
|
||||
CMeasureScript* measureScript = dynamic_cast<CMeasureScript*>(measure);
|
||||
if(measureScript)
|
||||
if (measureScript)
|
||||
{
|
||||
m_ScriptMeasures.push_back(measureScript);
|
||||
}
|
||||
@ -1992,7 +1992,7 @@ bool CMeterWindow::ReadSkin()
|
||||
{
|
||||
// Bind the meters to the measures
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2018,7 +2018,7 @@ void CMeterWindow::InitializeMeasures()
|
||||
{
|
||||
// Initalize all measures
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2041,7 +2041,7 @@ void CMeterWindow::InitializeMeters()
|
||||
{
|
||||
// Initalize all meters
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -2074,7 +2074,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
||||
|
||||
// Get the largest meter point
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
int mr = (*j)->GetX() + (*j)->GetW();
|
||||
w = max(w, mr);
|
||||
@ -2252,7 +2252,7 @@ bool CMeterWindow::ResizeWindow(bool reset)
|
||||
SetWindowSizeVariables(m_WindowW, m_WindowH);
|
||||
|
||||
// If Background is not set, take a copy from the desktop
|
||||
if(m_Background == NULL)
|
||||
if (m_Background == NULL)
|
||||
{
|
||||
if (m_BackgroundMode == BGMODE_COPY)
|
||||
{
|
||||
@ -2330,7 +2330,7 @@ void CMeterWindow::CreateRegion(bool clear)
|
||||
else
|
||||
{
|
||||
// Set window region if needed
|
||||
if(!m_BackgroundName.empty())
|
||||
if (!m_BackgroundName.empty())
|
||||
{
|
||||
if (m_WindowW != 0 && m_WindowH != 0)
|
||||
{
|
||||
@ -2435,7 +2435,7 @@ void CMeterWindow::Redraw()
|
||||
|
||||
// Draw the meters
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (!(*j)->GetTransformationMatrix().IsIdentity())
|
||||
{
|
||||
@ -2604,7 +2604,7 @@ void CMeterWindow::Update(bool nodraw)
|
||||
|
||||
// Update all measures
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
UpdateMeasure((*i), false);
|
||||
}
|
||||
@ -2613,7 +2613,7 @@ void CMeterWindow::Update(bool nodraw)
|
||||
bool bActiveTransition = false;
|
||||
bool bUpdate = false;
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (UpdateMeter((*j), bActiveTransition, false))
|
||||
{
|
||||
@ -2644,7 +2644,7 @@ void CMeterWindow::Update(bool nodraw)
|
||||
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
|
||||
// {
|
||||
// std::list<CMeasure*>::iterator i = m_Measures.begin();
|
||||
// for( ; i != m_Measures.end(); i++)
|
||||
// for ( ; i != m_Measures.end(); i++)
|
||||
// {
|
||||
// const char* sz = (*i)->GetStringValue(AUTOSCALE_ON, 1, 1, false);
|
||||
// if (sz && wcslen(sz) > 0)
|
||||
@ -2737,7 +2737,7 @@ LRESULT CMeterWindow::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
*/
|
||||
LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if(wParam == METERTIMER)
|
||||
if (wParam == METERTIMER)
|
||||
{
|
||||
Update(false);
|
||||
UpdateAboutStatistics(m_SkinName.c_str());
|
||||
@ -2753,12 +2753,12 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else if(wParam == TRANSITIONTIMER)
|
||||
else if (wParam == TRANSITIONTIMER)
|
||||
{
|
||||
// Redraw only if there is active transition still going
|
||||
bool bActiveTransition = false;
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if ((*j)->HasActiveTransition())
|
||||
{
|
||||
@ -2778,7 +2778,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
m_ActiveTransition = false;
|
||||
}
|
||||
}
|
||||
else if(wParam == MOUSETIMER)
|
||||
else if (wParam == MOUSETIMER)
|
||||
{
|
||||
if (!m_Rainmeter->IsMenuActive() && !m_Dragging)
|
||||
{
|
||||
@ -2819,7 +2819,7 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(wParam == FADETIMER)
|
||||
else if (wParam == FADETIMER)
|
||||
{
|
||||
DWORD ticks = GetTickCount();
|
||||
if (m_FadeStartTime == 0)
|
||||
@ -2946,7 +2946,7 @@ void CMeterWindow::ShowWindowIfAppropriate()
|
||||
}
|
||||
}
|
||||
|
||||
if(m_WindowHide)
|
||||
if (m_WindowHide)
|
||||
{
|
||||
if (!m_Hidden && !inside && !keyDown)
|
||||
{
|
||||
@ -3063,7 +3063,7 @@ void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meter
|
||||
bool drawCursor = false;
|
||||
|
||||
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
|
||||
for( ; j != m_Meters.rend(); ++j)
|
||||
for ( ; j != m_Meters.rend(); ++j)
|
||||
{
|
||||
// Hidden meters are ignored
|
||||
if ((*j)->IsHidden()) continue;
|
||||
@ -3255,7 +3255,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
|
||||
if (wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
|
||||
{
|
||||
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
|
||||
command += m_SkinPath;
|
||||
@ -3275,7 +3275,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
|
||||
{
|
||||
std::wstring command = L"\"" + m_SkinPath;
|
||||
command += L"\\";
|
||||
@ -3283,48 +3283,48 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
command += L"\"";
|
||||
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_REFRESH)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_REFRESH)
|
||||
{
|
||||
Refresh(false);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_VERYTOPMOST)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_VERYTOPMOST)
|
||||
{
|
||||
ChangeZPos(ZPOSITION_ONTOPMOST);
|
||||
WriteConfig();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_TOPMOST)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_TOPMOST)
|
||||
{
|
||||
ChangeZPos(ZPOSITION_ONTOP);
|
||||
WriteConfig();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_BOTTOM)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_BOTTOM)
|
||||
{
|
||||
ChangeZPos(ZPOSITION_ONBOTTOM);
|
||||
WriteConfig();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_NORMAL)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_NORMAL)
|
||||
{
|
||||
ChangeZPos(ZPOSITION_NORMAL);
|
||||
WriteConfig();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_ONDESKTOP)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_ONDESKTOP)
|
||||
{
|
||||
ChangeZPos(ZPOSITION_ONDESKTOP);
|
||||
WriteConfig();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_KEEPONSCREEN)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_KEEPONSCREEN)
|
||||
{
|
||||
SetKeepOnScreen(!m_KeepOnScreen);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_CLICKTHROUGH)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_CLICKTHROUGH)
|
||||
{
|
||||
SetClickThrough(!m_ClickThrough);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_DRAGGABLE)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_DRAGGABLE)
|
||||
{
|
||||
SetWindowDraggable(!m_WindowDraggable);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_HIDEONMOUSE)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_HIDEONMOUSE)
|
||||
{
|
||||
if (m_WindowHide == HIDEMODE_NONE)
|
||||
{
|
||||
@ -3337,7 +3337,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN)
|
||||
{
|
||||
if (m_WindowHide == HIDEMODE_NONE)
|
||||
{
|
||||
@ -3350,7 +3350,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT)
|
||||
{
|
||||
if (m_WindowHide == HIDEMODE_NONE)
|
||||
{
|
||||
@ -3363,25 +3363,25 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_REMEMBERPOSITION)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_REMEMBERPOSITION)
|
||||
{
|
||||
SetSavePosition(!m_SavePosition);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_SNAPTOEDGES)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_SNAPTOEDGES)
|
||||
{
|
||||
SetSnapEdges(!m_SnapEdges);
|
||||
}
|
||||
else if(wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90)
|
||||
else if (wParam >= ID_CONTEXT_SKINMENU_TRANSPARENCY_0 && wParam <= ID_CONTEXT_SKINMENU_TRANSPARENCY_90)
|
||||
{
|
||||
m_AlphaValue = (int)(255.0 - 230.0 * (double)(wParam - ID_CONTEXT_SKINMENU_TRANSPARENCY_0) / (double)(ID_CONTEXT_SKINMENU_TRANSPARENCY_90 - ID_CONTEXT_SKINMENU_TRANSPARENCY_0));
|
||||
WriteConfig();
|
||||
UpdateTransparency(m_AlphaValue, false);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_CLOSESKIN)
|
||||
else if (wParam == ID_CONTEXT_CLOSESKIN)
|
||||
{
|
||||
m_Rainmeter->DeactivateConfig(this, -1);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_FROMRIGHT)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_FROMRIGHT)
|
||||
{
|
||||
m_WindowXFromRight = !m_WindowXFromRight;
|
||||
|
||||
@ -3392,7 +3392,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_FROMBOTTOM)
|
||||
{
|
||||
m_WindowYFromBottom = !m_WindowYFromBottom;
|
||||
|
||||
@ -3403,7 +3403,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_XPERCENTAGE)
|
||||
{
|
||||
m_WindowXPercentage = !m_WindowXPercentage;
|
||||
|
||||
@ -3414,7 +3414,7 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
WriteConfig();
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE)
|
||||
else if (wParam == ID_CONTEXT_SKINMENU_YPERCENTAGE)
|
||||
{
|
||||
m_WindowYPercentage = !m_WindowYPercentage;
|
||||
|
||||
@ -3482,8 +3482,8 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(CError& error)
|
||||
{
|
||||
catch(CError& error)
|
||||
{
|
||||
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
@ -3721,7 +3721,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
if (m_SnapEdges && !(GetKeyState(VK_CONTROL) & 0x8000 || GetKeyState(VK_SHIFT) & 0x8000))
|
||||
{
|
||||
// only process movement (ignore anything without winpos values)
|
||||
if(wp->cx != 0 && wp->cy != 0)
|
||||
if (wp->cx != 0 && wp->cy != 0)
|
||||
{
|
||||
RECT workArea;
|
||||
|
||||
@ -3729,7 +3729,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
RECT windowRect = {wp->x, wp->y, (wp->x + m_WindowW), (wp->y + m_WindowH)};
|
||||
HMONITOR hMonitor = MonitorFromRect(&windowRect, MONITOR_DEFAULTTONULL);
|
||||
|
||||
if(hMonitor != NULL)
|
||||
if (hMonitor != NULL)
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(mi);
|
||||
@ -3744,7 +3744,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
// Snap to other windows
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
if ((*iter).second != this)
|
||||
{
|
||||
@ -3780,20 +3780,20 @@ void CMeterWindow::SnapToWindow(CMeterWindow* window, LPWINDOWPOS wp)
|
||||
|
||||
if (wp->y < y + h && wp->y + m_WindowH > y)
|
||||
{
|
||||
if((wp->x < SNAPDISTANCE + x) && (wp->x > x - SNAPDISTANCE)) wp->x = x;
|
||||
if((wp->x < SNAPDISTANCE + x + w) && (wp->x > x + w - SNAPDISTANCE)) wp->x = x + w;
|
||||
if ((wp->x < SNAPDISTANCE + x) && (wp->x > x - SNAPDISTANCE)) wp->x = x;
|
||||
if ((wp->x < SNAPDISTANCE + x + w) && (wp->x > x + w - SNAPDISTANCE)) wp->x = x + w;
|
||||
|
||||
if((wp->x + m_WindowW < SNAPDISTANCE + x) && (wp->x + m_WindowW > x - SNAPDISTANCE)) wp->x = x - m_WindowW;
|
||||
if((wp->x + m_WindowW < SNAPDISTANCE + x + w) && (wp->x + m_WindowW > x + w - SNAPDISTANCE)) wp->x = x + w - m_WindowW;
|
||||
if ((wp->x + m_WindowW < SNAPDISTANCE + x) && (wp->x + m_WindowW > x - SNAPDISTANCE)) wp->x = x - m_WindowW;
|
||||
if ((wp->x + m_WindowW < SNAPDISTANCE + x + w) && (wp->x + m_WindowW > x + w - SNAPDISTANCE)) wp->x = x + w - m_WindowW;
|
||||
}
|
||||
|
||||
if (wp->x < x + w && wp->x + m_WindowW > x)
|
||||
{
|
||||
if((wp->y < SNAPDISTANCE + y) && (wp->y > y - SNAPDISTANCE)) wp->y = y;
|
||||
if((wp->y < SNAPDISTANCE + y + h) && (wp->y > y + h - SNAPDISTANCE)) wp->y = y + h;
|
||||
if ((wp->y < SNAPDISTANCE + y) && (wp->y > y - SNAPDISTANCE)) wp->y = y;
|
||||
if ((wp->y < SNAPDISTANCE + y + h) && (wp->y > y + h - SNAPDISTANCE)) wp->y = y + h;
|
||||
|
||||
if((wp->y + m_WindowH < SNAPDISTANCE + y) && (wp->y + m_WindowH > y - SNAPDISTANCE)) wp->y = y - m_WindowH;
|
||||
if((wp->y + m_WindowH < SNAPDISTANCE + y + h) && (wp->y + m_WindowH > y + h - SNAPDISTANCE)) wp->y = y + h - m_WindowH;
|
||||
if ((wp->y + m_WindowH < SNAPDISTANCE + y) && (wp->y + m_WindowH > y - SNAPDISTANCE)) wp->y = y - m_WindowH;
|
||||
if ((wp->y + m_WindowH < SNAPDISTANCE + y + h) && (wp->y + m_WindowH > y + h - SNAPDISTANCE)) wp->y = y + h - m_WindowH;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4161,7 +4161,7 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test)
|
||||
{
|
||||
// Check if the hitpoint was over some meter
|
||||
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
|
||||
for( ; j != m_Meters.rend(); ++j)
|
||||
for ( ; j != m_Meters.rend(); ++j)
|
||||
{
|
||||
// Hidden meters are ignored
|
||||
if ((*j)->IsHidden()) continue;
|
||||
@ -4169,7 +4169,7 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test)
|
||||
if ((*j)->HitTest(x, y))
|
||||
{
|
||||
std::list<CMeasureScript*>::iterator k = m_ScriptMeasures.begin();
|
||||
for( ; k != m_ScriptMeasures.end(); ++k)
|
||||
for ( ; k != m_ScriptMeasures.end(); ++k)
|
||||
{
|
||||
(*k)->MeterMouseEvent((*j), mouse);
|
||||
}
|
||||
@ -4345,7 +4345,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
|
||||
|
||||
// Check if the hitpoint was over some meter
|
||||
std::list<CMeter*>::const_reverse_iterator j = m_Meters.rbegin();
|
||||
for( ; j != m_Meters.rend(); ++j)
|
||||
for ( ; j != m_Meters.rend(); ++j)
|
||||
{
|
||||
if (!(*j)->IsHidden() && (*j)->HitTest(x, y))
|
||||
{
|
||||
@ -4521,14 +4521,14 @@ LRESULT CALLBACK CMeterWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||
{
|
||||
CMeterWindow* Window = NULL;
|
||||
|
||||
if(uMsg == WM_CREATE)
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
// Fetch this window-object from the CreateStruct
|
||||
Window=(CMeterWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
|
||||
SetProp(hWnd, L"RAINMETER", Window);
|
||||
}
|
||||
else if(uMsg == WM_DESTROY)
|
||||
else if (uMsg == WM_DESTROY)
|
||||
{
|
||||
RemoveProp(hWnd, L"RAINMETER");
|
||||
}
|
||||
@ -4805,7 +4805,7 @@ std::wstring CMeterWindow::MakePathAbsolute(const std::wstring& path)
|
||||
CMeter* CMeterWindow::GetMeter(const std::wstring& meterName)
|
||||
{
|
||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); ++j)
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
if (_wcsicmp((*j)->GetName(), meterName.c_str()) == 0)
|
||||
{
|
||||
@ -4819,7 +4819,7 @@ CMeter* CMeterWindow::GetMeter(const std::wstring& meterName)
|
||||
CMeasure* CMeterWindow::GetMeasure(const std::wstring& measureName)
|
||||
{
|
||||
std::list<CMeasure*>::const_iterator i = m_Measures.begin();
|
||||
for( ; i != m_Measures.end(); ++i)
|
||||
for ( ; i != m_Measures.end(); ++i)
|
||||
{
|
||||
if (_wcsicmp((*i)->GetName(), measureName.c_str()) == 0)
|
||||
{
|
||||
|
@ -120,7 +120,7 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
|
||||
{
|
||||
Rainmeter=new CRainmeter;
|
||||
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
Result=Rainmeter->Initialize(ParentWnd, dllInst, szPath);
|
||||
}
|
||||
@ -142,7 +142,7 @@ int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath)
|
||||
*/
|
||||
void quitModule(HINSTANCE dllInst)
|
||||
{
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
Rainmeter->Quit(dllInst);
|
||||
delete Rainmeter;
|
||||
@ -372,7 +372,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData)
|
||||
*/
|
||||
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, size_t numOfArgs)
|
||||
{
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
std::vector<std::wstring> subStrings = CRainmeter::ParseString(arg);
|
||||
size_t subStringsSize = subStrings.size();
|
||||
@ -1593,9 +1593,9 @@ CRainmeter::CRainmeter() :
|
||||
INITCOMMONCONTROLSEX initCtrls = {sizeof(INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES};
|
||||
InitCommonControlsEx(&initCtrls);
|
||||
|
||||
// Initialize GDI+.
|
||||
GdiplusStartupInput gdiplusStartupInput;
|
||||
GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL);
|
||||
// Initialize GDI+.
|
||||
GdiplusStartupInput gdiplusStartupInput;
|
||||
GdiplusStartup(&m_GDIplusToken, &gdiplusStartupInput, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1644,7 +1644,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
{
|
||||
int Result=0;
|
||||
|
||||
if(Parent==NULL || Instance==NULL)
|
||||
if (Parent==NULL || Instance==NULL)
|
||||
{
|
||||
throw CError(CError::ERROR_NULL_PARAMETER, __LINE__, __FILE__);
|
||||
}
|
||||
@ -1656,7 +1656,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
|
||||
// Remove the module's name from the path
|
||||
WCHAR* pos = wcsrchr(tmpSzPath, L'\\');
|
||||
if(pos)
|
||||
if (pos)
|
||||
{
|
||||
*(pos + 1) = L'\0';
|
||||
}
|
||||
@ -1667,7 +1667,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
|
||||
m_Path = tmpSzPath;
|
||||
|
||||
if(!c_DummyLitestep) InitalizeLitestep();
|
||||
if (!c_DummyLitestep) InitalizeLitestep();
|
||||
|
||||
bool bDefaultIniLocation = false;
|
||||
|
||||
@ -1901,7 +1901,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
ScanForConfigs(m_SkinPath);
|
||||
ScanForThemes(GetSettingsPath() + L"Themes");
|
||||
|
||||
if(m_ConfigStrings.empty())
|
||||
if (m_ConfigStrings.empty())
|
||||
{
|
||||
std::wstring error = L"There are no available skins at:\n" + m_SkinPath;
|
||||
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
@ -1926,7 +1926,7 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
}
|
||||
|
||||
// If we're running as Litestep's plugin, register the !bangs
|
||||
if(!c_DummyLitestep)
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
int Msgs[] = { LM_GETREVID, 0 };
|
||||
// Register RevID message to Litestep
|
||||
@ -2534,7 +2534,7 @@ int CRainmeter::GetLoadOrder(const std::wstring& config)
|
||||
void CRainmeter::Quit(HINSTANCE dllInst)
|
||||
{
|
||||
// If we're running as Litestep's plugin, unregister the !bangs
|
||||
if(!c_DummyLitestep)
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
int Msgs[] = { LM_GETREVID, 0 };
|
||||
// Unregister RevID message
|
||||
@ -2624,10 +2624,10 @@ void CRainmeter::ScanForConfigs(const std::wstring& path)
|
||||
|
||||
int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu, bool DontRecurse)
|
||||
{
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearchIni; // Search handle returned by FindFirstFile
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
WIN32_FIND_DATA fileDataIni; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearchIni; // Search handle returned by FindFirstFile
|
||||
|
||||
if (!base.empty())
|
||||
{
|
||||
@ -2644,7 +2644,7 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
|
||||
do
|
||||
{
|
||||
if(hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearchIni == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
// Check whether the extension is ".ini"
|
||||
std::wstring ext = fileDataIni.cFileName;
|
||||
@ -2673,12 +2673,12 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
// Scan for folders
|
||||
std::wstring files = path + base;
|
||||
files += L"*";
|
||||
hSearch = FindFirstFile(files.c_str(), &fileData);
|
||||
hSearch = FindFirstFile(files.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
!(wcscmp(L"Backup", fileData.cFileName) == 0 && base.empty()) && // Skip the backup folder
|
||||
wcscmp(L".", fileData.cFileName) != 0 &&
|
||||
wcscmp(L"..", fileData.cFileName) != 0)
|
||||
@ -2702,7 +2702,7 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
|
||||
}
|
||||
} while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
FindClose(hSearch);
|
||||
|
||||
return index;
|
||||
}
|
||||
@ -2717,16 +2717,16 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
|
||||
m_Themes.clear();
|
||||
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
// Scan for folders
|
||||
std::wstring folders = path + L"\\*";
|
||||
hSearch = FindFirstFile(folders.c_str(), &fileData);
|
||||
hSearch = FindFirstFile(folders.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
|
||||
wcscmp(L".", fileData.cFileName) != 0 &&
|
||||
wcscmp(L"..", fileData.cFileName) != 0)
|
||||
{
|
||||
@ -2734,7 +2734,7 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
|
||||
}
|
||||
} while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
FindClose(hSearch);
|
||||
}
|
||||
|
||||
void CRainmeter::SaveSettings()
|
||||
@ -3080,7 +3080,7 @@ std::wstring CRainmeter::ParseCommand(const WCHAR* command, CMeterWindow* meterW
|
||||
{
|
||||
const std::list<CMeasure*>& measures = meterWindow->GetMeasures();
|
||||
std::list<CMeasure*>::const_iterator iter = measures.begin();
|
||||
for( ; iter != measures.end(); ++iter)
|
||||
for ( ; iter != measures.end(); ++iter)
|
||||
{
|
||||
if (_wcsicmp((*iter)->GetName(), measureName.c_str()) == 0)
|
||||
{
|
||||
@ -3153,7 +3153,7 @@ void CRainmeter::ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow)
|
||||
}
|
||||
|
||||
// Run the command
|
||||
if(strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())
|
||||
if (strCommand.c_str()[0] == L'!' && Rainmeter->GetDummyLitestep())
|
||||
{
|
||||
if (meterWindow)
|
||||
{
|
||||
@ -3603,7 +3603,7 @@ void CRainmeter::ReadStats()
|
||||
{
|
||||
WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
|
||||
|
||||
if(GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
if (GetPrivateProfileString(L"Statistics", L"Since", L"", tmpSz, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
m_StatsDate = tmpSz;
|
||||
}
|
||||
@ -3648,9 +3648,9 @@ void CRainmeter::ResetStats()
|
||||
{
|
||||
// Set the stats-date string
|
||||
struct tm *newtime;
|
||||
time_t long_time;
|
||||
time(&long_time);
|
||||
newtime = localtime(&long_time);
|
||||
time_t long_time;
|
||||
time(&long_time);
|
||||
newtime = localtime(&long_time);
|
||||
m_StatsDate = _wasctime(newtime);
|
||||
m_StatsDate.resize(m_StatsDate.size() - 1);
|
||||
|
||||
@ -3673,10 +3673,10 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow)
|
||||
// Show context menu, if no actions were executed
|
||||
HMENU menu = LoadMenu(m_Instance, MAKEINTRESOURCE(IDR_CONTEXT_MENU));
|
||||
|
||||
if(menu)
|
||||
if (menu)
|
||||
{
|
||||
HMENU subMenu = GetSubMenu(menu, 0);
|
||||
if(subMenu)
|
||||
if (subMenu)
|
||||
{
|
||||
if (!GetDummyLitestep())
|
||||
{
|
||||
@ -3915,10 +3915,10 @@ HMENU CRainmeter::CreateSkinMenu(CMeterWindow* meterWindow, int index, HMENU con
|
||||
CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_NORMAL, MF_BYCOMMAND | MF_CHECKED);
|
||||
}
|
||||
|
||||
if(meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if(meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetXFromRight()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMRIGHT, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetYFromBottom()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_FROMBOTTOM, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetXPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_XPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
if (meterWindow->GetYPercentage()) CheckMenuItem(posMenu, ID_CONTEXT_SKINMENU_YPERCENTAGE, MF_BYCOMMAND | MF_CHECKED);
|
||||
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
|
@ -982,7 +982,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||
// Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
|
||||
}
|
||||
|
@ -673,7 +673,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix2 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix2]);
|
||||
if (matrix2.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[1][i] = matrix2[i];
|
||||
}
|
||||
@ -686,7 +686,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix3 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix3]);
|
||||
if (matrix3.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[2][i] = matrix3[i];
|
||||
}
|
||||
@ -699,7 +699,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix4 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix4]);
|
||||
if (matrix4.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 0.
|
||||
{
|
||||
m_ColorMatrix->m[3][i] = matrix4[i];
|
||||
}
|
||||
@ -712,7 +712,7 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
std::vector<Gdiplus::REAL> matrix5 = parser.ReadFloats(section, m_ConfigArray[ConfigIndexColorMatrix5]);
|
||||
if (matrix5.size() == 5)
|
||||
{
|
||||
for(int i = 0; i < 4; ++i) // The fifth column must be 1.
|
||||
for (int i = 0; i < 4; ++i) // The fifth column must be 1.
|
||||
{
|
||||
m_ColorMatrix->m[4][i] = matrix5[i];
|
||||
}
|
||||
@ -721,19 +721,19 @@ void CTintedImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
m_NeedsTinting = (oldGreyScale != m_GreyScale || !CompareColorMatrix(&oldColorMatrix, m_ColorMatrix));
|
||||
|
||||
std::wstring flip = parser.ReadString(section, m_ConfigArray[ConfigIndexImageFlip], L"NONE");
|
||||
if(_wcsicmp(flip.c_str(), L"NONE") == 0)
|
||||
if (_wcsicmp(flip.c_str(), L"NONE") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipNone;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"HORIZONTAL") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipX;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"VERTICAL") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"VERTICAL") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipY;
|
||||
}
|
||||
else if(_wcsicmp(flip.c_str(), L"BOTH") == 0)
|
||||
else if (_wcsicmp(flip.c_str(), L"BOTH") == 0)
|
||||
{
|
||||
m_Flip = RotateNoneFlipXY;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ CTrayWindow::~CTrayWindow()
|
||||
|
||||
BOOL CTrayWindow::AddTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
@ -125,7 +125,7 @@ BOOL CTrayWindow::AddTrayIcon()
|
||||
|
||||
res = Shell_NotifyIcon(NIM_ADD, &tnid);
|
||||
}
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::RemoveTrayIcon()
|
||||
@ -145,12 +145,12 @@ BOOL CTrayWindow::RemoveTrayIcon()
|
||||
m_TrayIcon = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
@ -166,8 +166,8 @@ BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
tnid.uFlags = NIF_ICON;
|
||||
tnid.hIcon = m_TrayIcon;
|
||||
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
||||
return res;
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
||||
return res;
|
||||
}
|
||||
|
||||
HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
@ -351,7 +351,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = new Bitmap(imageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
if (Ok != status)
|
||||
{
|
||||
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
|
||||
delete m_Bitmap;
|
||||
@ -382,7 +382,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
static CTrayWindow* tray = NULL;
|
||||
|
||||
if(uMsg == WM_CREATE)
|
||||
if (uMsg == WM_CREATE)
|
||||
{
|
||||
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
}
|
||||
@ -400,19 +400,19 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
LSExecute(NULL, RAINMETER_DOWNLOADS, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOW_HELP)
|
||||
else if (wParam == ID_CONTEXT_SHOW_HELP)
|
||||
{
|
||||
LSExecute(NULL, revision_beta ? RAINMETER_MANUALBETA : RAINMETER_MANUAL, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_NEW_VERSION)
|
||||
else if (wParam == ID_CONTEXT_NEW_VERSION)
|
||||
{
|
||||
LSExecute(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_REFRESH)
|
||||
else if (wParam == ID_CONTEXT_REFRESH)
|
||||
{
|
||||
PostMessage(tray->GetWindow(), WM_TRAY_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
else if (wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
{
|
||||
// Check if the file exists
|
||||
const std::wstring& log = Rainmeter->GetLogFile();
|
||||
@ -423,57 +423,57 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_STARTLOG)
|
||||
else if (wParam == ID_CONTEXT_STARTLOG)
|
||||
{
|
||||
Rainmeter->StartLogging();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_STOPLOG)
|
||||
else if (wParam == ID_CONTEXT_STOPLOG)
|
||||
{
|
||||
Rainmeter->StopLogging();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DELETELOGFILE)
|
||||
else if (wParam == ID_CONTEXT_DELETELOGFILE)
|
||||
{
|
||||
Rainmeter->DeleteLogFile();
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DEBUGLOG)
|
||||
else if (wParam == ID_CONTEXT_DEBUGLOG)
|
||||
{
|
||||
Rainmeter->SetDebug(!CRainmeter::GetDebug());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_DISABLEDRAG)
|
||||
else if (wParam == ID_CONTEXT_DISABLEDRAG)
|
||||
{
|
||||
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_EDITCONFIG)
|
||||
else if (wParam == ID_CONTEXT_EDITCONFIG)
|
||||
{
|
||||
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
|
||||
command += Rainmeter->GetIniFile();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_MANAGETHEMES)
|
||||
else if (wParam == ID_CONTEXT_MANAGETHEMES)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
|
||||
command += L"RainThemes\\RainThemes.exe\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_MANAGESKINS)
|
||||
else if (wParam == ID_CONTEXT_MANAGESKINS)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
|
||||
command += L"RainBrowser\\RainBrowser.exe\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_QUIT)
|
||||
else if (wParam == ID_CONTEXT_QUIT)
|
||||
{
|
||||
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
|
||||
quitModule(Rainmeter->GetInstance());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
||||
else if (wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
||||
{
|
||||
std::wstring command = L"\"" + Rainmeter->GetSkinPath();
|
||||
command += L"\"";
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
|
||||
else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
|
||||
{
|
||||
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
|
||||
|
||||
@ -487,7 +487,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
||||
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
||||
{
|
||||
wParam = wParam & 0x0ffff;
|
||||
|
||||
@ -523,7 +523,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
if (index < (int)windows.size())
|
||||
{
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); ++iter)
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
--index;
|
||||
if (index < 0)
|
||||
@ -589,7 +589,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
if (wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetSkinPath();
|
||||
|
||||
@ -601,7 +601,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
{
|
||||
std::wstring path = Rainmeter->GetSettingsPath();
|
||||
|
||||
@ -613,7 +613,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetPluginPath();
|
||||
|
||||
@ -625,7 +625,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetPath();
|
||||
|
||||
@ -637,7 +637,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
||||
else if (wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
||||
{
|
||||
const std::wstring& path = Rainmeter->GetLogFile();
|
||||
|
||||
@ -649,7 +649,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
||||
else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
||||
{
|
||||
const std::wstring& editor = Rainmeter->GetConfigEditor();
|
||||
|
||||
@ -661,7 +661,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
|
||||
else if (wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
|
||||
{
|
||||
std::wstring commandline = Rainmeter->GetCommandLine();
|
||||
|
||||
@ -673,7 +673,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
|
||||
else if (wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
|
||||
{
|
||||
UINT versioncheck = (Rainmeter->GetDisableVersionCheck() * (Rainmeter->GetDisableVersionCheck() + Rainmeter->GetNewVersion()));
|
||||
|
||||
@ -681,7 +681,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
||||
else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
||||
{
|
||||
BOOL debug = Rainmeter->GetDebug();
|
||||
|
||||
@ -689,7 +689,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_STATS_DATE)
|
||||
else if (wParam == RAINMETER_QUERY_ID_STATS_DATE)
|
||||
{
|
||||
const std::wstring& date = Rainmeter->GetStatsDate();
|
||||
|
||||
@ -701,7 +701,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteL();
|
||||
|
||||
@ -713,7 +713,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteR();
|
||||
|
||||
@ -725,7 +725,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteM();
|
||||
|
||||
@ -737,7 +737,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDL();
|
||||
|
||||
@ -749,7 +749,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDR();
|
||||
|
||||
@ -761,7 +761,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
|
||||
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
|
||||
{
|
||||
const std::wstring& tray = Rainmeter->GetTrayExecuteDM();
|
||||
|
||||
@ -773,7 +773,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
|
||||
else if (wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
|
||||
{
|
||||
BOOL islitestep = !Rainmeter->GetDummyLitestep();
|
||||
|
||||
@ -785,19 +785,19 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
return 1;
|
||||
|
||||
case WM_COPYDATA:
|
||||
if(Rainmeter)
|
||||
if (Rainmeter)
|
||||
{
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
||||
if(cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
|
||||
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
|
||||
{
|
||||
std::wstring SkinName((LPTSTR) cds->lpData);
|
||||
std::map<std::wstring, CMeterWindow*> MeterWindows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = MeterWindows.find(SkinName);
|
||||
if(iter != MeterWindows.end())
|
||||
if (iter != MeterWindows.end())
|
||||
{
|
||||
return (LRESULT) iter->second->GetWindow();
|
||||
}
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@ -833,14 +833,14 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
break;
|
||||
|
||||
case LM_GETREVID:
|
||||
if(lParam != NULL)
|
||||
if (lParam != NULL)
|
||||
{
|
||||
char* Buffer=(char*)lParam;
|
||||
if(wParam==0)
|
||||
if (wParam==0)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s", APPVERSION);
|
||||
}
|
||||
else if(wParam==1)
|
||||
else if (wParam==1)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s %s, Rainy", APPVERSION, __DATE__);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ double LuaScript::RunFunctionDouble(const char* p_strFuncName)
|
||||
// Push the function onto the stack
|
||||
lua_getfield(m_pState, -1, p_strFuncName);
|
||||
|
||||
if(lua_pcall(m_pState, 0, 1, 0))
|
||||
if (lua_pcall(m_pState, 0, 1, 0))
|
||||
{
|
||||
LuaManager::ReportErrors(m_pState);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
WCHAR* token;
|
||||
|
||||
token = wcstok(names, L";");
|
||||
while(token != NULL)
|
||||
while (token != NULL)
|
||||
{
|
||||
splittedNames.push_back(token);
|
||||
token = wcstok(NULL, L";");
|
||||
@ -153,11 +153,11 @@ double Update2(UINT id)
|
||||
LONGLONG newValue = 0;
|
||||
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
for (size_t i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
@ -197,14 +197,14 @@ double Update2(UINT id)
|
||||
//
|
||||
// // Then substract the excluded processes
|
||||
// std::vector< std::wstring >::iterator j = measure->excludes.begin();
|
||||
// for( ; j != measure->excludes.end(); j++)
|
||||
// for ( ; j != measure->excludes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue; // Adding means actually substraction
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// int val = 10000000 - (UINT)(newValue - measure->oldValue);
|
||||
// if (val < 0) val = 0;
|
||||
@ -216,14 +216,14 @@ double Update2(UINT id)
|
||||
// {
|
||||
// // Add the included processes
|
||||
// std::vector< std::wstring >::iterator j = measure->includes.begin();
|
||||
// for( ; j != measure->includes.end(); j++)
|
||||
// for ( ; j != measure->includes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue;
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// if (measure->oldValue != 0)
|
||||
// {
|
||||
// value = (UINT)(newValue - measure->oldValue);
|
||||
// }
|
||||
@ -244,7 +244,7 @@ double Update2(UINT id)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
@ -266,7 +266,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
if (i != g_CPUMeasures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_CPUMeasures.erase(i);
|
||||
@ -291,17 +291,17 @@ void UpdateProcesses()
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(L"Process"))
|
||||
if (snapshot.TakeSnapshot(L"Process"))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(L"Process");
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if (_wcsicmp(name, L"_Total") == 0)
|
||||
{
|
||||
@ -309,11 +309,11 @@ void UpdateProcesses()
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 8)
|
||||
if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
ProcessValues values;
|
||||
values.name = name;
|
||||
|
@ -19,119 +19,119 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectInstance::CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
{
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
m_fDummy = fDummy;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObjectInstance::GetObjectInstanceName(
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
{
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
|
||||
{
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByIndex( DWORD index )
|
||||
{
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
return MakeCounter( pCurrentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetFirstCounter( void )
|
||||
{
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetNextCounter( void )
|
||||
{
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
|
||||
{
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
@ -19,65 +19,65 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectList::CPerfObjectList(
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
{
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetFirstPerfObject( void )
|
||||
{
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetNextPerfObject( void )
|
||||
{
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
|
||||
{
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
@ -19,105 +19,105 @@
|
||||
#include "perfcntr.h"
|
||||
|
||||
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData )
|
||||
PBYTE const pData, DWORD cbData )
|
||||
{
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter( void )
|
||||
{
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
|
||||
{
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
|
||||
{
|
||||
// Do better formatting!!! Check length!!!
|
||||
// Do better formatting!!! Check length!!!
|
||||
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
break;
|
||||
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
@ -105,21 +105,21 @@ double Update2(UINT id)
|
||||
double value = 0;
|
||||
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
PerfMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
if (measure)
|
||||
{
|
||||
ULONGLONG longvalue;
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
measure->CounterName.c_str());
|
||||
|
||||
if(measure->Difference)
|
||||
if (measure->Difference)
|
||||
{
|
||||
// Compare with the old value
|
||||
if(!measure->FirstTime)
|
||||
if (!measure->FirstTime)
|
||||
{
|
||||
value = (double)(longvalue - measure->OldValue);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
if (i != g_Measures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_Measures.erase(i);
|
||||
@ -166,7 +166,7 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
WCHAR name[256];
|
||||
ULONGLONG value = 0;
|
||||
|
||||
if(ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
if (ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
{
|
||||
// Unable to continue
|
||||
return 0;
|
||||
@ -175,21 +175,21 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(ObjectName))
|
||||
if (snapshot.TakeSnapshot(ObjectName))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(ObjectName);
|
||||
|
||||
if(pPerfObj)
|
||||
if (pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
for (pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if (InstanceName != NULL && wcslen(InstanceName) > 0)
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
if (pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if(_wcsicmp(InstanceName, name) != 0)
|
||||
if (_wcsicmp(InstanceName, name) != 0)
|
||||
{
|
||||
delete pObjInst;
|
||||
continue;
|
||||
@ -203,23 +203,23 @@ ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(CounterName);
|
||||
if(pPerfCntr != NULL)
|
||||
if (pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 1)
|
||||
if (pPerfCntr->GetSize() == 1)
|
||||
{
|
||||
value = *(BYTE*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 2)
|
||||
else if (pPerfCntr->GetSize() == 2)
|
||||
{
|
||||
value = *(WORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 4)
|
||||
else if (pPerfCntr->GetSize() == 4)
|
||||
{
|
||||
value = *(DWORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 8)
|
||||
else if (pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
value = *(ULONGLONG*)data;
|
||||
}
|
||||
|
@ -19,78 +19,78 @@
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
{
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetFirstObjectInstance( void )
|
||||
{
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetNextObjectInstance( void )
|
||||
{
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize )
|
||||
{
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
}
|
@ -21,145 +21,145 @@ PBYTE CPerfSnapshot::c_pBuffer = NULL;
|
||||
DWORD CPerfSnapshot::c_cbBufferSize = 0;
|
||||
|
||||
CPerfSnapshot::CPerfSnapshot(
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
}
|
||||
|
||||
CPerfSnapshot::~CPerfSnapshot( void )
|
||||
{
|
||||
DisposeSnapshot();
|
||||
DisposeSnapshot();
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems )
|
||||
{
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer;
|
||||
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::DisposeSnapshot( void )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pPerfDataHeader = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::CleanUp( void )
|
||||
{
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
c_cbBufferSize = 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
CPerfSnapshot::GetNumObjectTypes( void )
|
||||
{
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize )
|
||||
{
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVOID
|
||||
CPerfSnapshot::GetPostHeaderPointer( void )
|
||||
{
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn,
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
{
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
|
||||
|
||||
DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn);
|
||||
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
@ -16,143 +16,143 @@
|
||||
#include "Titledb.h"
|
||||
|
||||
CPerfTitleDatabase::CPerfTitleDatabase(
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
{
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
RegCloseKey( hKeyPerflib );
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CPerfTitleDatabase::~CPerfTitleDatabase( )
|
||||
{
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
}
|
||||
|
||||
PTSTR
|
||||
CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index )
|
||||
{
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
return m_TitleStrings[ index ];
|
||||
}
|
||||
|
||||
unsigned
|
||||
CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString )
|
||||
{
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
if (pData->destAddr == INADDR_NONE)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
{
|
||||
LPHOSTENT pHost;
|
||||
|
||||
@ -236,7 +236,7 @@ DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
pData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -99,7 +99,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"PowerState", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"ACLINE", type) == 0)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
hSearch = FindFirstFile(searchPath.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
@ -223,7 +223,7 @@ void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
}
|
||||
}
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
while (FindNextFile(hSearch, &fileData));
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
@ -140,9 +140,9 @@ double Update2(UINT id)
|
||||
SHQUERYRBINFO RecycleBinInfo = { 0 };
|
||||
RecycleBinInfo.cbSize = sizeof( RecycleBinInfo ); // Tell size of structure
|
||||
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
if (SHQueryRecycleBin( NULL, &RecycleBinInfo ) == S_OK)
|
||||
{
|
||||
if (dataType == SIZERECYCLE)
|
||||
{
|
||||
@ -164,7 +164,7 @@ double Update2(UINT id)
|
||||
double retVal = 0;
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
double tempVal;
|
||||
std::wstring strd = tokens.at(i);
|
||||
@ -209,14 +209,14 @@ LPCTSTR GetPluginAuthor()
|
||||
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::wstring bang = args;
|
||||
std::wstring bang = args;
|
||||
std::wstring driveSet = g_DriveList[id];
|
||||
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBin") == 0)
|
||||
{ //Empty the Recycle Bin
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, NULL ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -229,20 +229,20 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), NULL ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_wcsicmp(bang.c_str(), L"EmptyBinSilent") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if(_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{ //Empty the Recycle Bin (no prompt)
|
||||
if (_wcsicmp(driveSet.c_str(), L"ALL") == 0)
|
||||
{
|
||||
if(SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
if (SHEmptyRecycleBin( NULL, NULL, SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ) == S_OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -255,21 +255,21 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
std::wstring toSplit(driveSet.begin(), driveSet.end());
|
||||
Tokenize(toSplit, tokens, L"|");
|
||||
|
||||
for(int i=0;i < tokens.size(); i++)
|
||||
for (int i=0;i < tokens.size(); i++)
|
||||
{
|
||||
std::wstring strd = tokens.at(i);
|
||||
SHEmptyRecycleBin( NULL, strd.c_str(), SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND ); // empty bin
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"OpenBin") == 0)
|
||||
{ //Open the Recycle Bin folder
|
||||
//system("explorer.exe /N,::{645FF040-5081-101B-9F08-00AA002F954E}");
|
||||
std::wstring szCmd = L"explorer.exe";
|
||||
std::wstring szParm= L"/N,::{645FF040-5081-101B-9F08-00AA002F954E}";
|
||||
ShellExecute(NULL,L"open",szCmd.c_str(),szParm.c_str(),NULL,SW_SHOW);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ UINT Update(UINT id)
|
||||
{
|
||||
if (processName)
|
||||
{
|
||||
if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
if (EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
{
|
||||
if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer)))
|
||||
{
|
||||
|
@ -159,7 +159,7 @@ double Update2(UINT id)
|
||||
std::map<UINT, TempScale>::const_iterator scale = g_Scales.find(id);
|
||||
std::map<UINT, UINT>::const_iterator number = g_Numbers.find(id);
|
||||
|
||||
if(type == g_Types.end() || number == g_Numbers.end())
|
||||
if (type == g_Types.end() || number == g_Numbers.end())
|
||||
{
|
||||
return 0.0; // No id in the map. How this can be ????
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"SysInfoType", L"");
|
||||
if(type)
|
||||
if (type)
|
||||
{
|
||||
if (_wcsicmp(L"COMPUTER_NAME", type) == 0)
|
||||
{
|
||||
@ -256,8 +256,8 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -321,11 +321,11 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
if (data >= 1000)
|
||||
{
|
||||
data = data-999;
|
||||
for(UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
for (UINT i=0; i<ipTable->dwNumEntries; i++)
|
||||
{
|
||||
if((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
if ((ipTable->table[i].wType)&MIB_IPADDR_DISCONNECTED) continue;
|
||||
data--;
|
||||
if(data==0)
|
||||
if (data==0)
|
||||
{
|
||||
DWORD ip = ipTable->table[i].dwAddr;
|
||||
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
|
||||
@ -423,8 +423,8 @@ double Update2(UINT id)
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
if (typeIter == g_Types.end()) return NULL;
|
||||
if (dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
@ -433,9 +433,9 @@ double Update2(UINT id)
|
||||
data = (*dataIter).second;
|
||||
}
|
||||
|
||||
if(data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
if (data) //For speed purposes, only check if they specify a non-primary monitor.
|
||||
{
|
||||
if(GetSystemMetrics(SM_CMONITORS)>32)
|
||||
if (GetSystemMetrics(SM_CMONITORS)>32)
|
||||
{
|
||||
std::wstring error = L"That's alot of monitors! 32 is the max.";
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
@ -633,17 +633,17 @@ BOOL CheckConnection()
|
||||
static HRASCONN g_hRasConn=NULL;
|
||||
RASCONNSTATUS rasStatus;
|
||||
LPRASCONN lpRasConn=NULL;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
|
||||
if(g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
if (g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
cbBuf=sizeof(RASCONN);
|
||||
if(((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
if (((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
lpRasConn->dwSize=sizeof(RASCONN);
|
||||
if(0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if(cConn!=0) {
|
||||
if (0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if (cConn!=0) {
|
||||
g_hRasConn=lpRasConn->hrasconn;
|
||||
}
|
||||
}
|
||||
@ -651,19 +651,19 @@ BOOL CheckConnection()
|
||||
}
|
||||
}
|
||||
|
||||
if(g_hRasConn!=NULL) {
|
||||
if (g_hRasConn!=NULL) {
|
||||
// get connection status
|
||||
rasStatus.dwSize=sizeof(RASCONNSTATUS);
|
||||
dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus );
|
||||
if(dwRet==0) {
|
||||
if (dwRet==0) {
|
||||
// Check for connection
|
||||
if(rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
if (rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
} else {
|
||||
g_hRasConn=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
|
@ -45,28 +45,28 @@ DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR i
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
|
||||
if(TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if(TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if(TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if(TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if(TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
|
||||
else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
|
||||
else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
|
||||
else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
|
||||
else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
hWndRainmeterControl = FindWindow(_T("DummyRainWClass"), _T("Rainmeter control window"));
|
||||
hWndMessageWindow = CreateMessageWindow();
|
||||
}
|
||||
InstanceCount++;
|
||||
|
||||
if(!PluginRegistered && FindDexpotWindow())
|
||||
if (!PluginRegistered && FindDexpotWindow())
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
@ -82,9 +82,9 @@ UINT DexpotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
void DexpotMeasure::Finalize()
|
||||
{
|
||||
InstanceCount--;
|
||||
if(InstanceCount == 0)
|
||||
if (InstanceCount == 0)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
SendNotifyMessage(hWndDexpot, DEX_UNREGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
PluginRegistered = FALSE;
|
||||
@ -113,7 +113,7 @@ void DexpotMeasure::OnDexpotStarted()
|
||||
|
||||
BOOL DexpotMeasure::FindDexpotWindow()
|
||||
{
|
||||
if(IsWindow(hWndDexpot)) return TRUE;
|
||||
if (IsWindow(hWndDexpot)) return TRUE;
|
||||
hWndDexpot = FindWindow(DEXPOTCLASS, DEXPOTTITLE);
|
||||
return hWndDexpot != NULL;
|
||||
}
|
||||
@ -153,14 +153,14 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
{
|
||||
case DEX_SWITCHED:
|
||||
CurrentDesktop = HIWORD(lParam);
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnSwitched(LOWORD(lParam), HIWORD(lParam), LOWORD(wParam), HIWORD(wParam));
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCOUNTCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopCountChanged((int)wParam);
|
||||
}
|
||||
@ -168,21 +168,21 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
|
||||
case DEX_SHUTDOWN:
|
||||
PluginRegistered = FALSE;
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnShutdown();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case DEX_DESKTOPCONFIGURATIONCHANGED:
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDesktopConfigurationChanged();
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_COPYDATA:
|
||||
if((HWND) wParam == hWndDexpot)
|
||||
if ((HWND) wParam == hWndDexpot)
|
||||
{
|
||||
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
||||
switch(LOWORD(cds->dwData))
|
||||
@ -198,17 +198,17 @@ LRESULT CALLBACK DexpotMeasure::WindowProc(HWND hWnd, UINT message, WPARAM wPara
|
||||
return 0;
|
||||
|
||||
default:
|
||||
if(message == WM_DEXPOTSTARTED)
|
||||
if (message == WM_DEXPOTSTARTED)
|
||||
{
|
||||
hWndDexpot = (HWND) wParam;
|
||||
if(!hWndDexpot) FindDexpotWindow();
|
||||
if(hWndDexpot)
|
||||
if (!hWndDexpot) FindDexpotWindow();
|
||||
if (hWndDexpot)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_REGISTERPLUGIN, 0, (LPARAM) hWndMessageWindow);
|
||||
CurrentDesktop = (int) SendMessage(hWndDexpot, DEX_GETCURRENTDESKTOP, 0, 0);
|
||||
PluginRegistered = TRUE;
|
||||
}
|
||||
for(std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
for (std::set<DexpotMeasure*>::iterator i = DexpotMeasures.begin(); i != DexpotMeasures.end(); ++i)
|
||||
{
|
||||
(*i)->OnDexpotStarted();
|
||||
}
|
||||
@ -233,8 +233,8 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
CountType = Total;
|
||||
LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if(_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
if (_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
|
||||
else if (_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;
|
||||
|
||||
DexpotMeasure::Initialize(iniFile, section);
|
||||
return 20;
|
||||
@ -242,19 +242,19 @@ UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotDesktopCountMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
if (PluginRegistered) DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
}
|
||||
|
||||
UINT DexpotDesktopCountMeasure::Update()
|
||||
{
|
||||
if(CountType == Rows) return 1;
|
||||
if (CountType == Rows) return 1;
|
||||
else return DesktopCount;
|
||||
}
|
||||
|
||||
void DexpotDesktopCountMeasure::OnDesktopCountChanged(int NewCount)
|
||||
{
|
||||
DesktopCount = NewCount;
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
@ -279,7 +279,7 @@ UINT DexpotCurrentDesktopMeasure::Update()
|
||||
|
||||
void DexpotCurrentDesktopMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(OnChange.length()) SendBang(OnChange);
|
||||
if (OnChange.length()) SendBang(OnChange);
|
||||
}
|
||||
|
||||
|
||||
@ -305,12 +305,12 @@ UINT DexpotVDMActiveMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
void DexpotVDMActiveMeasure::OnShutdown()
|
||||
{
|
||||
if(OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
if (OnDeactivate.length()) SendBang(OnDeactivate);
|
||||
}
|
||||
|
||||
void DexpotVDMActiveMeasure::OnDexpotStarted()
|
||||
{
|
||||
if(OnActivate.length()) SendBang(OnActivate);
|
||||
if (OnActivate.length()) SendBang(OnActivate);
|
||||
}
|
||||
|
||||
|
||||
@ -322,13 +322,13 @@ DexpotSwitchDesktopMeasure::DexpotSwitchDesktopMeasure(HMODULE instance, UINT id
|
||||
|
||||
void DexpotSwitchDesktopMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
DWORD Desktop;
|
||||
|
||||
if(_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if(_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if(_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
if (_tcsicmp(args, _T("next")) == 0) Desktop = MAKELPARAM(0, 1);
|
||||
else if (_tcsicmp(args, _T("prev")) == 0) Desktop = MAKELPARAM(0, 2);
|
||||
else if (_tcsicmp(args, _T("back")) == 0) Desktop = MAKELPARAM(0, 3);
|
||||
else Desktop = _ttoi(args);
|
||||
|
||||
SendNotifyMessage(hWndDexpot, DEX_SWITCHDESKTOP, 0, Desktop);
|
||||
@ -356,7 +356,7 @@ UINT DexpotScreenshotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
UINT DexpotScreenshotMeasure::Update()
|
||||
{
|
||||
if(RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
if (RefreshOnUpdate && (DesktopNumber == 0 || DesktopNumber == CurrentDesktop))
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -375,7 +375,7 @@ void DexpotScreenshotMeasure::InitializeData()
|
||||
|
||||
void DexpotScreenshotMeasure::OnSwitched(int FromDesktop, int ToDesktop, WORD Flags, WORD Trigger)
|
||||
{
|
||||
if(DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
if (DesktopNumber == FromDesktop || DesktopNumber == 0)
|
||||
{
|
||||
UpdateScreenshot();
|
||||
}
|
||||
@ -385,11 +385,11 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
{
|
||||
int Desktop = DesktopNumber == 0 ? CurrentDesktop : DesktopNumber;
|
||||
int nBytes = 0;
|
||||
BYTE *pBytes = NULL;
|
||||
BYTE *pBytes = NULL;
|
||||
HANDLE fm;
|
||||
HANDLE mutex;
|
||||
|
||||
if(!IsWindow(hWndDexpot)) return;
|
||||
if (!IsWindow(hWndDexpot)) return;
|
||||
|
||||
int DesktopWidth = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPWIDTH, Desktop, 0);
|
||||
int DesktopHeight = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPHEIGHT, Desktop, 0);
|
||||
@ -398,9 +398,9 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
WaitForSingleObject(mutex, 2000);
|
||||
fm = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, DesktopWidth * DesktopHeight * 4, L"Local\\DexpotScreenshotFilemap");
|
||||
pBytes = (BYTE*) MapViewOfFile(fm, FILE_MAP_ALL_ACCESS, 0, 0, 0);
|
||||
if(pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
if (pBytes) nBytes = (int) SendMessage(hWndDexpot, DEX_GETSCREENSHOT, Desktop, 0);
|
||||
|
||||
if(nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
if (nBytes > 0 && nBytes == DesktopWidth * DesktopHeight * 4)
|
||||
{
|
||||
HDC ScreenDC;
|
||||
HDC MemDC;
|
||||
@ -415,10 +415,10 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
int ScaledHeight = Height;
|
||||
int ScaledWidth = Width;
|
||||
|
||||
if(ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if(ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if(ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if(ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
if (ScaledHeight == 0) ScaledHeight = (int) ((float) DesktopHeight * (ScaledWidth / (float) DesktopWidth) + .5f);
|
||||
if (ScaledWidth == 0) ScaledWidth = (int) ((float) DesktopWidth * (ScaledHeight / (float) DesktopHeight) + .5f);
|
||||
if (ScaledHeight == 0) ScaledHeight = DesktopHeight;
|
||||
if (ScaledWidth == 0) ScaledWidth = DesktopWidth;
|
||||
|
||||
ZeroMemory(&bmi.bmiHeader, sizeof(BITMAPINFOHEADER));
|
||||
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
@ -453,7 +453,7 @@ void DexpotScreenshotMeasure::UpdateScreenshot()
|
||||
bmfh.bfType = 0x4d42;
|
||||
|
||||
std::ofstream ofs(OutputFile.c_str(), std::ios_base::binary);
|
||||
if(ofs)
|
||||
if (ofs)
|
||||
{
|
||||
ofs.write((char*) &bmfh, sizeof(BITMAPFILEHEADER));
|
||||
ofs.write((char*) &bmi, sizeof(BITMAPINFOHEADER));
|
||||
@ -492,7 +492,7 @@ UINT DexpotDesktopNameMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
{
|
||||
UINT Desktop = (DesktopNumber == 0 ? CurrentDesktop : DesktopNumber) - 1;
|
||||
if(Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
if (Desktop >= 0 && Desktop < DesktopNames.size())
|
||||
{
|
||||
return DesktopNames[Desktop].c_str();
|
||||
}
|
||||
@ -505,18 +505,18 @@ LPCTSTR DexpotDesktopNameMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopNameMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopNames.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPTITLE, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -535,8 +535,8 @@ void DexpotDesktopNameMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopNameMeasure::SetDesktopName(UINT Desktop, std::wstring &Name)
|
||||
{
|
||||
if(--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
if (--Desktop >= DesktopNames.size()) DesktopNames.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopNames[Desktop] = Name;
|
||||
}
|
||||
|
||||
|
||||
@ -554,12 +554,12 @@ UINT DexpotDesktopWallpaperMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
|
||||
LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
{
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
SystemParametersInfo(SPI_GETDESKWALLPAPER, STRINGBUFFER_SIZE, StringBuffer, 0);
|
||||
return StringBuffer;
|
||||
}
|
||||
else if(DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
else if (DesktopNumber > 0 && (UINT) DesktopNumber <= DesktopWallpapers.size())
|
||||
{
|
||||
return DesktopWallpapers[DesktopNumber - 1].c_str();
|
||||
}
|
||||
@ -570,18 +570,18 @@ LPCTSTR DexpotDesktopWallpaperMeasure::GetString(UINT flags)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::InitializeData()
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
int DesktopCount = (int) SendMessage(hWndDexpot, DEX_GETDESKTOPCOUNT, 0, 0);
|
||||
DesktopWallpapers.resize(DesktopCount);
|
||||
if(DesktopNumber == 0)
|
||||
if (DesktopNumber == 0)
|
||||
{
|
||||
for(int i = 1; i <= DesktopCount; i++)
|
||||
for (int i = 1; i <= DesktopCount; i++)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, i, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
}
|
||||
else if(DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
else if (DesktopNumber > 0 && DesktopNumber <= DesktopCount)
|
||||
{
|
||||
SendMessage(hWndDexpot, DEX_GETDESKTOPWALLPAPER, DesktopNumber, (LPARAM) hWndMessageWindow);
|
||||
}
|
||||
@ -604,8 +604,8 @@ void DexpotDesktopWallpaperMeasure::OnDesktopCountChanged(int NewCount)
|
||||
|
||||
void DexpotDesktopWallpaperMeasure::SetDesktopWallpaper(UINT Desktop, std::wstring &Wallpaper)
|
||||
{
|
||||
if(--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if(Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
if (--Desktop >= DesktopWallpapers.size()) DesktopWallpapers.resize(Desktop + 1);
|
||||
if (Desktop >= 0) DesktopWallpapers[Desktop] = Wallpaper;
|
||||
}
|
||||
|
||||
|
||||
@ -617,7 +617,7 @@ DexpotCommandMeasure::DexpotCommandMeasure(HMODULE instance, UINT id) : DexpotMe
|
||||
|
||||
void DexpotCommandMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
if(PluginRegistered)
|
||||
if (PluginRegistered)
|
||||
{
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
|
@ -28,7 +28,7 @@ std::map<std::wstring, VirtuaWinMeasure::MeasureType> VirtuaWinMeasure::StringTo
|
||||
|
||||
VirtuaWinMeasure::VirtuaWinMeasure(HMODULE instance, UINT id) : VDMeasure(instance, id)
|
||||
{
|
||||
if(StringToType.size() == 0)
|
||||
if (StringToType.size() == 0)
|
||||
{
|
||||
StringToType.insert(std::make_pair(std::wstring(L"VDMActive"), VDMActive));
|
||||
StringToType.insert(std::make_pair(std::wstring(L"DesktopCount"), DesktopCountTotal));
|
||||
@ -45,7 +45,7 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
{
|
||||
std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
|
||||
std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
|
||||
if(i != StringToType.end())
|
||||
if (i != StringToType.end())
|
||||
{
|
||||
Type = i->second;
|
||||
}
|
||||
@ -62,9 +62,9 @@ UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
|
||||
case DesktopCountTotal:
|
||||
{
|
||||
LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
|
||||
if(_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if(_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if(FindVirtuaWinWindow())
|
||||
if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
|
||||
else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
|
||||
if (FindVirtuaWinWindow())
|
||||
{
|
||||
return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
|
||||
}
|
||||
@ -81,7 +81,7 @@ void VirtuaWinMeasure::Finalize()
|
||||
|
||||
UINT VirtuaWinMeasure::Update()
|
||||
{
|
||||
if(!FindVirtuaWinWindow())
|
||||
if (!FindVirtuaWinWindow())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -130,7 +130,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
{
|
||||
INT32 Desktop;
|
||||
|
||||
if(!FindVirtuaWinWindow()) return;
|
||||
if (!FindVirtuaWinWindow()) return;
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
@ -142,7 +142,7 @@ void VirtuaWinMeasure::ExecuteBang(LPCTSTR args)
|
||||
|
||||
BOOL VirtuaWinMeasure::FindVirtuaWinWindow()
|
||||
{
|
||||
if(IsWindow(vwHandle)) return TRUE;
|
||||
if (IsWindow(vwHandle)) return TRUE;
|
||||
vwHandle = FindWindow(_T("VirtuaWinMainClass"), _T("VirtuaWinMainClass"));
|
||||
return vwHandle != NULL;
|
||||
}
|
||||
|
@ -24,38 +24,38 @@
|
||||
This plugin aims to give Rainmeter skins access to various virtual desktop
|
||||
managers through a common interface. The following VDMs are supported:
|
||||
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
* Dexpot
|
||||
* VirtuaWin
|
||||
|
||||
To add support for another virtual desktop manager,
|
||||
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
1) implement a new class derived from VDMeasure
|
||||
2) include its header file below
|
||||
3) add a new case for the "VDManager" config string in the Initialize
|
||||
funtion below
|
||||
|
||||
Different types of measures are identified using the "VDMeasureType" config
|
||||
string, i.e.
|
||||
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
[VirtualDesktopsMeasure]
|
||||
Measure=Plugin
|
||||
Plugin=VirtualDesktops.dll
|
||||
VDManager=SomeVDM
|
||||
VDMeasureType=...
|
||||
|
||||
The following basic measure types have to be implemented:
|
||||
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
* VDMActive: returns 1 when the VDM is running, 0 otherwise
|
||||
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
* DesktopCount: returns the number of virtual desktops available; when
|
||||
"VDDesktopCount=X" or "VDDesktopCount=Y" is given, returns
|
||||
the number of columns or rows, respectively, in a grid of
|
||||
desktops
|
||||
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
* CurrentDesktop: returns the number of the currently active desktop
|
||||
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
* SwitchDesktop: when sent a desktop number as a bang, switches to the
|
||||
corresponding desktop
|
||||
|
||||
You're welcome to add any other measure types that suit the feature set of
|
||||
the virtual desktop manager in question. Examples can be found in the
|
||||
@ -93,16 +93,16 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
VDMeasure *Measure = NULL;
|
||||
LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));
|
||||
|
||||
if(_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
|
||||
{
|
||||
Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
|
||||
}
|
||||
else if(_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
|
||||
{
|
||||
Measure = new VirtuaWinMeasure(instance, id);
|
||||
}
|
||||
|
||||
if(Measure)
|
||||
if (Measure)
|
||||
{
|
||||
Measures.insert(std::make_pair(id, Measure));
|
||||
return Measure->Initialize(iniFile, section);
|
||||
@ -114,7 +114,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->Update();
|
||||
}
|
||||
@ -125,7 +125,7 @@ UINT Update(UINT id)
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
return i->second->GetString(flags);
|
||||
}
|
||||
@ -136,7 +136,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->ExecuteBang(args);
|
||||
}
|
||||
@ -145,7 +145,7 @@ void ExecuteBang(LPCTSTR args, UINT id)
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, VDMeasure*>::iterator i = Measures.find(id);
|
||||
if(i != Measures.end())
|
||||
if (i != Measures.end())
|
||||
{
|
||||
i->second->Finalize();
|
||||
delete i->second;
|
||||
|
@ -603,7 +603,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
data->downloadFile = ReadConfigString(section, L"DownloadFile", L"");
|
||||
data->debugFileLocation = ReadConfigString(section, L"Debug2File", L"c:\\WebParserDump.txt");
|
||||
|
||||
if(data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
if (data->debugFileLocation.find(L"\\") == std::wstring::npos)
|
||||
{
|
||||
std::wstring str = data->iniFile.substr(0,data->iniFile.find_last_of(L"\\")+1);
|
||||
str += data->debugFileLocation;
|
||||
@ -706,7 +706,7 @@ double Update2(UINT id)
|
||||
|
||||
// Find the data for this instance (the data structure is not changed by anyone so this should be safe)
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
urlData = (*urlIter).second;
|
||||
}
|
||||
@ -837,7 +837,7 @@ unsigned __stdcall NetworkThreadProc(void* pParam)
|
||||
urlData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
@ -1505,7 +1505,7 @@ unsigned __stdcall NetworkDownloadThreadProc(void* pParam)
|
||||
urlData->dlThreadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1518,7 +1518,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
if (((*urlIter).second)->download)
|
||||
@ -1546,7 +1546,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
if (urlIter != g_UrlData.end())
|
||||
{
|
||||
if (((*urlIter).second)->threadHandle)
|
||||
{
|
||||
|
@ -90,9 +90,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
DWORD dwErr;
|
||||
g_Instances++;
|
||||
//Create WINLAN API Handle
|
||||
if(hClient == NULL){
|
||||
if (hClient == NULL){
|
||||
dwErr = WlanOpenHandle( WLAN_API_VERSION, NULL, &dwNegotiatedVersion, &hClient );
|
||||
if( ERROR_SUCCESS != dwErr ){
|
||||
if ( ERROR_SUCCESS != dwErr ){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to open WLAN API Handle. Error code (%d): %s",(int)dwErr,getDot11str(dwErr,5));
|
||||
Log(buffer);
|
||||
@ -100,9 +100,9 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
}
|
||||
//Query list of WLAN interfaces
|
||||
if(pIntfList == NULL){
|
||||
if (pIntfList == NULL){
|
||||
dwErr= WlanEnumInterfaces(hClient, NULL, &pIntfList);
|
||||
if(( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
if (( ERROR_SUCCESS != dwErr) || (&pIntfList->dwNumberOfItems <= 0)){
|
||||
WCHAR buffer[256];
|
||||
wsprintf(buffer, L"WifiStatus.dll: Unable to find any WLAN interfaces/adapters. Error code %d",(int) dwErr);
|
||||
Log(buffer);
|
||||
@ -113,7 +113,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
LPCTSTR data = ReadConfigString(section, L"WifiIntfID", L"");
|
||||
|
||||
if ((data != NULL) && (_wcsicmp(L"", data) != 0)){
|
||||
if(_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
if (_wtoi(data) < (int)pIntfList->dwNumberOfItems){
|
||||
pInterface = &pIntfList->InterfaceInfo[_wtoi(data)];
|
||||
} else {
|
||||
WCHAR buffer[256];
|
||||
@ -158,7 +158,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
//Select type of measure
|
||||
MEASURETYPE infoType = UNKNOWN;
|
||||
LPCTSTR type = ReadConfigString(section, L"WifiInfoType", L"");
|
||||
if(type){
|
||||
if (type){
|
||||
if (_wcsicmp(L"SSID", type) == 0){
|
||||
infoType=SSID;
|
||||
}
|
||||
@ -202,11 +202,11 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Get measure id, and identify type
|
||||
//std::map<UINT, MEASURETYPE>::iterator typeIter = g_Types.find(id);
|
||||
//if(typeIter == g_Types.end()) return NULL;
|
||||
//if (typeIter == g_Types.end()) return NULL;
|
||||
MEASURETYPE current_type = g_meas_data[id].type;
|
||||
switch(current_type)
|
||||
{
|
||||
@ -217,11 +217,11 @@ UINT Update(UINT id)
|
||||
DWORD dwErr;
|
||||
GUID& intfGUID = pInterface->InterfaceGuid;
|
||||
dwErr = WlanQueryInterface( hClient, &intfGUID, wlan_intf_opcode_current_connection, NULL, &outsize, (PVOID*)&wlan_cattr, NULL );
|
||||
if( ERROR_SUCCESS != dwErr){
|
||||
if ( ERROR_SUCCESS != dwErr){
|
||||
return 0;
|
||||
}
|
||||
int retval = (int)wlan_cattr->wlanAssociationAttributes.wlanSignalQuality;
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
return retval;
|
||||
|
||||
//Transfer rates will go here
|
||||
@ -232,7 +232,7 @@ UINT Update(UINT id)
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
if(pInterface == NULL) return NULL;
|
||||
if (pInterface == NULL) return NULL;
|
||||
|
||||
//Some variables for data manipulation in this function
|
||||
static WCHAR buffer[128];
|
||||
@ -260,12 +260,12 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
switch(current_type)
|
||||
{
|
||||
case LIST:
|
||||
if(ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
if (ERROR_SUCCESS != dwLErr){return L"Error";}
|
||||
|
||||
if (!g_meas_data[id].listInit){//Check if netlist has memory allocated already
|
||||
//Size of network name can be up to 64 chars, set to 80 to add room for delimiters
|
||||
g_meas_data[id].netlist = (WCHAR*)malloc( 80 * sizeof(WCHAR) * g_meas_data[id].listMax);
|
||||
if(g_meas_data[id].netlist == NULL){
|
||||
if (g_meas_data[id].netlist == NULL){
|
||||
WCHAR debug[256];
|
||||
wsprintf(debug, L"WifiStatus.dll: Unable to allocate memory for network list.");
|
||||
Log(buffer);
|
||||
@ -280,24 +280,24 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
memset(buffer,'\0',128);
|
||||
|
||||
//Check all items in WLAN NETWORK LIST
|
||||
for(int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if(printed == g_meas_data[id].listMax)
|
||||
for (int i=0; i < (int)pwnl->dwNumberOfItems ; i++){
|
||||
if (printed == g_meas_data[id].listMax)
|
||||
break;
|
||||
|
||||
//SSID is in UCHAR, convert to WCHAR
|
||||
mbstowcs(buffer,(char*)pwnl->Network[i].dot11Ssid.ucSSID,pwnl->Network[i].dot11Ssid.uSSIDLength);
|
||||
|
||||
//Prevent duplicates that result from profiles, check using SSID
|
||||
if((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
if ((wcsstr(g_meas_data[id].netlist,buffer)== NULL)&&(_wcsicmp(L"", buffer) != 0)){
|
||||
printed++;
|
||||
if(listStyle > 0){
|
||||
if (listStyle > 0){
|
||||
wsprintf(g_meas_data[id].netlist,L"%s%s",g_meas_data[id].netlist,buffer);
|
||||
memset(buffer,'\0',128);
|
||||
if(listStyle == 1 || listStyle == 3){
|
||||
if (listStyle == 1 || listStyle == 3){
|
||||
//ADD PHY type
|
||||
wsprintf(buffer,L" @%s", getDot11str(pwnl->Network[i].dot11PhyTypes[0],4));
|
||||
}
|
||||
if(listStyle == 2 || listStyle == 3){
|
||||
if (listStyle == 2 || listStyle == 3){
|
||||
//ADD cipher and authentication
|
||||
wsprintf(buffer,L"%s (%s:%s)",buffer,getDot11str(pwnl->Network[i].dot11DefaultCipherAlgorithm,1)
|
||||
,getDot11str(pwnl->Network[i].dot11DefaultAuthAlgorithm,2));
|
||||
@ -312,7 +312,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case SSID:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -323,7 +323,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case PHY:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -331,7 +331,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case ENCRYPTION:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -339,7 +339,7 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
case AUTH:
|
||||
if(ERROR_SUCCESS != dwCErr){
|
||||
if (ERROR_SUCCESS != dwCErr){
|
||||
bIntfError = true;
|
||||
break;
|
||||
}
|
||||
@ -351,15 +351,15 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
break;
|
||||
|
||||
}
|
||||
if(wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if(pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
if (wlan_cattr!=NULL)WlanFreeMemory(wlan_cattr);
|
||||
if (pwnl!=NULL)WlanFreeMemory(pwnl);
|
||||
|
||||
if(bNetList)
|
||||
if (bNetList)
|
||||
return g_meas_data[id].netlist;
|
||||
if(bIntfError)
|
||||
if (bIntfError)
|
||||
return L"-1";
|
||||
else {
|
||||
if(bInvalidType)
|
||||
if (bInvalidType)
|
||||
return NULL;
|
||||
else
|
||||
return buffer;
|
||||
@ -369,11 +369,11 @@ LPCTSTR GetString(UINT id, UINT flags)
|
||||
/*
|
||||
switches from winlanapi.h + SDK
|
||||
in: -DOT11 ENUM (converted to int)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
-type of ENUM (cipher=1, auth=2, status=3, phy=4, otherwise=error strings)
|
||||
out: String to be returned by measure
|
||||
*/
|
||||
LPCTSTR getDot11str(int dot11enum,int type){
|
||||
if(type ==1){
|
||||
if (type ==1){
|
||||
switch(dot11enum){
|
||||
case DOT11_CIPHER_ALGO_NONE:
|
||||
return L"NONE";
|
||||
@ -413,7 +413,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
return L"???";
|
||||
}
|
||||
}
|
||||
else if(type==3){
|
||||
else if (type==3){
|
||||
switch(dot11enum){
|
||||
case wlan_interface_state_connected:
|
||||
return L"";
|
||||
@ -423,7 +423,7 @@ LPCTSTR getDot11str(int dot11enum,int type){
|
||||
return L"(connecting...)";
|
||||
}
|
||||
}
|
||||
else if(type==4){
|
||||
else if (type==4){
|
||||
switch(dot11enum){
|
||||
case dot11_phy_type_unknown:
|
||||
return L"???";
|
||||
@ -476,11 +476,11 @@ void Finalize(HMODULE instance, UINT id)
|
||||
g_meas_data.erase(i1);
|
||||
}
|
||||
g_Instances--;
|
||||
if(hClient != NULL && g_Instances == 0){
|
||||
if (hClient != NULL && g_Instances == 0){
|
||||
WlanCloseHandle(hClient, NULL);
|
||||
hClient = NULL;
|
||||
}
|
||||
if(pIntfList != NULL && g_Instances == 0){
|
||||
if (pIntfList != NULL && g_Instances == 0){
|
||||
WlanFreeMemory(pIntfList);
|
||||
pIntfList = NULL;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
||||
|
||||
#define SAFE_RELEASE(punk) \
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
@ -148,7 +148,7 @@ HRESULT RegisterDevice(PCWSTR devID)
|
||||
hr = S_FALSE;
|
||||
}
|
||||
UnInitCom();
|
||||
return hr;
|
||||
return hr;
|
||||
}
|
||||
|
||||
std::wstring GetDefaultID()
|
||||
@ -294,7 +294,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
UINT count;
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
{
|
||||
UnInitCom();
|
||||
return 0;
|
||||
@ -302,10 +302,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
endpointIDs = std::vector<std::wstring>(count);
|
||||
|
||||
for (UINT i = 0; i < count; i++)
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
|
||||
// Get pointer to endpoint number i.
|
||||
// Get pointer to endpoint number i.
|
||||
if (pCollection->Item(i, &pEndpoint) == S_OK)
|
||||
{
|
||||
// Get the endpoint ID string.
|
||||
|
@ -469,7 +469,7 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
}
|
||||
|
||||
const wchar_t* type = ReadConfigString(section, L"Command", L"");
|
||||
for(int i = 0; i < COMMAND_COUNT; i++)
|
||||
for (int i = 0; i < COMMAND_COUNT; i++)
|
||||
{
|
||||
if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user