- Removed unneeded NULL checks.
- Other code tweaks and cleanups.
This commit is contained in:
spx 2011-11-08 10:32:57 +00:00
parent 10f7504b86
commit a209bf15d0
17 changed files with 242 additions and 258 deletions

View File

@ -64,13 +64,11 @@ void CConfigParser::Initialize(LPCTSTR filename, CRainmeter* pRainmeter, CMeterW
{
m_Filename = filename;
m_Measures.clear();
m_Sections.clear();
m_Values.clear();
m_BuiltInVariables.clear();
m_Variables.clear();
m_Measures.clear();
m_Values.clear();
m_Sections.clear();
m_FoundSections.clear();
m_ListVariables.clear();
m_StyleTemplate.clear();
m_LastUsedStyle.clear();
@ -89,6 +87,7 @@ void CConfigParser::Initialize(LPCTSTR filename, CRainmeter* pRainmeter, CMeterW
ReadVariables();
// Clear and minimize
std::unordered_set<std::wstring>().swap(m_FoundSections);
std::vector<std::wstring>().swap(m_ListVariables);
}
@ -126,9 +125,10 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
*/
void CConfigParser::ReadVariables()
{
for (size_t i = 0, isize = m_ListVariables.size(); i < isize; ++i)
std::vector<std::wstring>::const_iterator iter = m_ListVariables.begin();
for ( ; iter != m_ListVariables.end(); ++iter)
{
SetVariable(m_ListVariables[i], ReadString(L"Variables", m_ListVariables[i].c_str(), L"", false));
SetVariable((*iter), ReadString(L"Variables", (*iter).c_str(), L"", false));
}
}
@ -495,7 +495,8 @@ bool CConfigParser::ReplaceVariables(std::wstring& result)
{
loop = false;
}
} while (loop);
}
while (loop);
return replaced;
}
@ -568,7 +569,8 @@ bool CConfigParser::ReplaceMeasures(std::wstring& result)
{
loop = false;
}
} while (loop);
}
while (loop);
}
return replaced;
@ -703,9 +705,10 @@ std::vector<Gdiplus::REAL> CConfigParser::ReadFloats(LPCTSTR section, LPCTSTR ke
// Tokenize and parse the floats
std::vector<std::wstring> tokens = Tokenize(tmp, L";");
for (size_t i = 0, isize = tokens.size(); i < isize; ++i)
std::vector<std::wstring>::const_iterator iter = tokens.begin();
for ( ; iter != tokens.end(); ++iter)
{
result.push_back((Gdiplus::REAL)ParseDouble(tokens[i], 0));
result.push_back((Gdiplus::REAL)ParseDouble((*iter), 0));
}
}
return result;
@ -1078,7 +1081,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
if (config == NULL)
{
// Get all the sections
while (true)
do
{
items[0] = 0;
DWORD res = GetPrivateProfileSectionNames(items, itemsSize, iniRead.c_str());
@ -1098,6 +1101,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
itemsSize *= 2;
items = new WCHAR[itemsSize];
}
while (true);
// Read the sections
pos = items;
@ -1143,7 +1147,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
bool isMetadata = (config == NULL && _wcsicmp((*iter).c_str(), L"Metadata") == 0);
// Read all "key=value" from the section
while (true)
do
{
items[0] = 0;
DWORD res = GetPrivateProfileSection((*iter).c_str(), items, itemsSize, iniRead.c_str());
@ -1157,6 +1161,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
itemsSize *= 2;
items = new WCHAR[itemsSize];
}
while (true);
pos = items;
while (pos < epos)
@ -1170,8 +1175,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
std::wstring value = key.substr(sep + 1, len - sep);
key.erase(sep);
std::wstring lowerKey = StrToLower(key);
if (foundKeys.insert(lowerKey).second)
if (foundKeys.insert(StrToLowerC(key)).second)
{
// Trim surrounded quotes from value
std::wstring::size_type valueLen = value.length();
@ -1183,7 +1187,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
value.assign(value, 1, valueLen);
}
if (wcsncmp(lowerKey.c_str(), L"@include", 8) == 0)
if (wcsncmp(key.c_str(), L"@include", 8) == 0)
{
ReadVariables();
ReplaceVariables(value);
@ -1203,7 +1207,7 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
if (isVariables)
{
m_ListVariables.push_back(lowerKey);
m_ListVariables.push_back(key);
}
}
}
@ -1235,7 +1239,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
std::wstring strTmp = strSection + L"::";
strTmp += strKey;
m_Values[StrToLower(strTmp)] = strValue;
m_Values[StrToLowerC(strTmp)] = strValue;
}
//==============================================================================
@ -1251,7 +1255,7 @@ void CConfigParser::DeleteValue(const std::wstring& strSection, const std::wstri
std::wstring strTmp = strSection + L"::";
strTmp += strKey;
std::unordered_map<std::wstring, std::wstring>::iterator iter = m_Values.find(StrToLower(strTmp));
std::unordered_map<std::wstring, std::wstring>::iterator iter = m_Values.find(StrToLowerC(strTmp));
if (iter != m_Values.end())
{
m_Values.erase(iter);
@ -1272,7 +1276,7 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
std::wstring strTmp = strSection + L"::";
strTmp += strKey;
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLower(strTmp));
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLowerC(strTmp));
if (iter != m_Values.end())
{
return (*iter).second;

View File

@ -109,8 +109,9 @@ private:
static void SetMultiMonitorVariables(bool reset);
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower); return strTmp; }
static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower); return strTmp; }
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); return StrToLowerC(strTmp); }
static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); return StrToLowerC(strTmp); }
static std::wstring& StrToLowerC(std::wstring& str) { std::transform(str.begin(), str.end(), str.begin(), ::towlower); return str; }
std::wstring m_Filename;
@ -125,9 +126,10 @@ private:
bool m_LastValueDefined;
std::vector<std::wstring> m_Sections; // The sections must be an ordered array
std::unordered_map<std::wstring, std::wstring> m_Values;
std::unordered_set<std::wstring> m_FoundSections;
std::vector<std::wstring> m_ListVariables;
std::unordered_map<std::wstring, std::wstring> m_Values;
std::unordered_map<std::wstring, std::wstring> m_BuiltInVariables; // Built-in variables
std::unordered_map<std::wstring, std::wstring> m_Variables; // User-defined variables

View File

@ -207,7 +207,8 @@ bool CMeasure::MakePlainSubstitute(std::wstring& str, size_t index)
str.replace(pos, m_Substitute[index].first.length(), m_Substitute[index].second);
start = pos + m_Substitute[index].second.length();
}
} while (pos != std::wstring::npos);
}
while (pos != std::wstring::npos);
return true;
}
@ -313,7 +314,8 @@ const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
utf8str.replace(start, length, result);
offset = start + result.length();
}
} while (true);
}
while (true);
// Release memory used for the compiled pattern
pcre_free(re);
@ -343,7 +345,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
{
if (buffer.empty()) return true;
while (!buffer.empty())
do
{
std::wstring word1 = ExtractWord(buffer);
std::wstring sep = ExtractWord(buffer);
@ -358,6 +360,7 @@ bool CMeasure::ParseSubstitute(std::wstring buffer)
sep = ExtractWord(buffer);
if (!sep.empty() && sep != L",") return false;
}
while (!buffer.empty());
return true;
}
@ -772,11 +775,7 @@ CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow, cons
{
// Comparison is caseinsensitive
if (*measure == L'\0')
{
return NULL;
}
else if (_wcsicmp(L"CPU", measure) == 0)
if (_wcsicmp(L"CPU", measure) == 0)
{
return new CMeasureCPU(meterWindow, name);
}

View File

@ -185,7 +185,8 @@ bool CMeasureCPU::Update()
buf = new BYTE[bufSize];
}
++loop;
} while (loop < 5);
}
while (loop < 5);
if (status != STATUS_SUCCESS) // failed
{

View File

@ -54,11 +54,8 @@ CMeasureScript::~CMeasureScript()
void CMeasureScript::DeleteLuaScript()
{
if (m_LuaScript)
{
delete m_LuaScript;
m_LuaScript = NULL;
}
delete m_LuaScript;
m_LuaScript = NULL;
m_HasInitializeFunction = false;
m_HasUpdateFunction = false;

View File

@ -54,10 +54,10 @@ CMeter::CMeter(CMeterWindow* meterWindow, const WCHAR* name) : m_MeterWindow(met
m_ToolTipWidth(),
m_ToolTipDelay(),
m_ToolTipType(false),
m_ToolTipHidden(meterWindow ? meterWindow->GetMeterToolTipHidden() : false),
m_ToolTipHidden(meterWindow->GetMeterToolTipHidden()),
m_ToolTipHandle(),
m_HasMouseAction(false),
m_MouseActionCursor(meterWindow ? meterWindow->GetMeterMouseActionCursor() : true),
m_MouseActionCursor(meterWindow->GetMeterMouseActionCursor()),
m_MouseOver(false),
m_RelativeX(POSITION_ABSOLUTE),
m_RelativeY(POSITION_ABSOLUTE),
@ -107,7 +107,7 @@ void CMeter::Initialize()
*/
int CMeter::GetX(bool abs)
{
if (m_RelativeX != POSITION_ABSOLUTE && m_MeterWindow)
if (m_RelativeX != POSITION_ABSOLUTE)
{
if (m_RelativeMeter == NULL)
{
@ -155,7 +155,7 @@ int CMeter::GetX(bool abs)
*/
int CMeter::GetY(bool abs)
{
if (m_RelativeY != POSITION_ABSOLUTE && m_MeterWindow)
if (m_RelativeY != POSITION_ABSOLUTE)
{
if (m_RelativeMeter == NULL)
{
@ -402,7 +402,7 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"", false);
m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
m_MouseActionCursor = 0!=parser.ReadInt(section, L"MouseActionCursor", m_MeterWindow ? m_MeterWindow->GetMeterMouseActionCursor() : true);
m_MouseActionCursor = 0!=parser.ReadInt(section, L"MouseActionCursor", m_MeterWindow->GetMeterMouseActionCursor());
m_HasMouseAction =
( !m_LeftMouseUpAction.empty() || !m_LeftMouseDownAction.empty() || !m_LeftMouseDoubleClickAction.empty()
@ -414,7 +414,7 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L"");
m_ToolTipWidth = (int)parser.ReadFormula(section, L"ToolTipWidth", 1000);
m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0);
m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow ? m_MeterWindow->GetMeterToolTipHidden() : false);
m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden());
int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
if (updateDivider != m_UpdateDivider)
@ -439,11 +439,9 @@ void CMeter::ReadConfig(CConfigParser& parser, const WCHAR* section)
}
else if (!matrix.empty())
{
if (m_Transformation)
{
delete m_Transformation;
m_Transformation = NULL;
}
delete m_Transformation;
m_Transformation = NULL;
LogWithArgs(LOG_ERROR, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str());
}
@ -496,14 +494,18 @@ 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)
{
return new CMeterHistogram(meterWindow, name);
}
else if (_wcsicmp(L"STRING", meter) == 0)
if (_wcsicmp(L"STRING", meter) == 0)
{
return new CMeterString(meterWindow, name);
}
else if (_wcsicmp(L"IMAGE", meter) == 0)
{
return new CMeterImage(meterWindow, name);
}
else if (_wcsicmp(L"HISTOGRAM", meter) == 0)
{
return new CMeterHistogram(meterWindow, name);
}
else if (_wcsicmp(L"BAR", meter) == 0)
{
return new CMeterBar(meterWindow, name);
@ -512,10 +514,6 @@ CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow, const WCHA
{
return new CMeterBitmap(meterWindow, name);
}
else if (_wcsicmp(L"IMAGE", meter) == 0)
{
return new CMeterImage(meterWindow, name);
}
else if (_wcsicmp(L"LINE", meter) == 0)
{
return new CMeterLine(meterWindow, name);
@ -613,7 +611,8 @@ void CMeter::ReadMeasureNames(CConfigParser& parser, const WCHAR* section, std::
loop = false;
}
++i;
} while(loop);
}
while(loop);
}
/*
@ -646,7 +645,8 @@ bool CMeter::ReplaceMeasures(const std::vector<std::wstring>& stringValues, std:
start = pos + stringValues[i - 1].length();
replaced = true;
}
} while (pos != std::wstring::npos);
}
while (pos != std::wstring::npos);
}
}
@ -665,9 +665,10 @@ void CMeter::ReplaceToolTipMeasures(std::wstring& str)
if (!m_AllMeasures.empty())
{
// Get the values for the measures
for (size_t i = 0, isize = m_AllMeasures.size(); i < isize; ++i)
std::vector<CMeasure*>::const_iterator iter = m_AllMeasures.begin();
for ( ; iter != m_AllMeasures.end(); ++iter)
{
stringValues.push_back(m_AllMeasures[i]->GetStringValue(AUTOSCALE_ON, 1, 0, false));
stringValues.push_back((*iter)->GetStringValue(AUTOSCALE_ON, 1, 0, false));
}
}
else if (m_Measure != NULL)
@ -692,6 +693,8 @@ void CMeter::ReplaceToolTipMeasures(std::wstring& str)
*/
void CMeter::CreateToolTip(CMeterWindow* meterWindow)
{
HWND hMeterWindow = m_MeterWindow->GetWindow();
HINSTANCE hInstance = m_MeterWindow->GetMainObject()->GetInstance();
DWORD style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP;
if (m_ToolTipType)
@ -707,21 +710,16 @@ void CMeter::CreateToolTip(CMeterWindow* meterWindow)
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
m_MeterWindow->GetWindow(),
hMeterWindow,
NULL,
m_MeterWindow->GetMainObject()->GetInstance(),
hInstance,
NULL);
if (hwndTT)
{
SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
TOOLINFO ti = {sizeof(TOOLINFO)};
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = m_MeterWindow->GetWindow();
ti.hinst = m_MeterWindow->GetMainObject()->GetInstance();
ti.rect = GetMeterRect();
TOOLINFO ti = {sizeof(TOOLINFO), TTF_SUBCLASS, hMeterWindow, 0, GetMeterRect(), hInstance};
SendMessage(hwndTT, TTM_ADDTOOL, NULL, (LPARAM) (LPTOOLINFO) &ti);
@ -759,23 +757,23 @@ void CMeter::UpdateToolTip()
if (!m_ToolTipIcon.empty())
{
if (!_wcsicmp(m_ToolTipIcon.c_str(), L"INFO"))
if (_wcsicmp(m_ToolTipIcon.c_str(), L"INFO") == 0)
{
hIcon = (HICON) TTI_INFO;
}
else if (!_wcsicmp(m_ToolTipIcon.c_str(), L"WARNING"))
else if (_wcsicmp(m_ToolTipIcon.c_str(), L"WARNING") == 0)
{
hIcon = (HICON) TTI_WARNING;
}
else if (!_wcsicmp(m_ToolTipIcon.c_str(), L"ERROR"))
else if (_wcsicmp(m_ToolTipIcon.c_str(), L"ERROR") == 0)
{
hIcon = (HICON) TTI_ERROR;
}
else if (!_wcsicmp(m_ToolTipIcon.c_str(), L"QUESTION"))
else if (_wcsicmp(m_ToolTipIcon.c_str(), L"QUESTION") == 0)
{
hIcon = LoadIcon(NULL, IDI_QUESTION);
}
else if (!_wcsicmp(m_ToolTipIcon.c_str(), L"SHIELD"))
else if (_wcsicmp(m_ToolTipIcon.c_str(), L"SHIELD") == 0)
{
hIcon = LoadIcon(NULL, IDI_SHIELD);
}

View File

@ -131,7 +131,8 @@ bool CMeterBitmap::HitTest(int x, int y)
{
tmpValue /= realFrames;
}
} while (tmpValue > 0);
}
while (tmpValue > 0);
}
Rect rect(GetX(), GetY(), m_W * numOfNums + (numOfNums - 1) * m_Separation, m_H);
@ -332,7 +333,8 @@ bool CMeterBitmap::Draw(Graphics& graphics)
{
tmpValue /= m_FrameCount;
}
} while (tmpValue > 0);
}
while (tmpValue > 0);
}
// Blit the images
@ -407,7 +409,8 @@ bool CMeterBitmap::Draw(Graphics& graphics)
transitionValue /= realFrames;
}
--numOfNums;
} while (numOfNums > 0);
}
while (numOfNums > 0);
}
else
{

View File

@ -45,7 +45,7 @@ CMeterButton::CMeterButton(CMeterWindow* meterWindow, const WCHAR* name) : CMete
m_Bitmaps(),
m_State(BUTTON_STATE_NORMAL),
m_Clicked(false),
m_Executable(false)
m_Focus(false)
{
}
@ -75,11 +75,8 @@ void CMeterButton::Initialize()
for (int i = 0; i < BUTTON_FRAMES; ++i)
{
if (m_Bitmaps[i])
{
delete m_Bitmaps[i];
m_Bitmaps[i] = NULL;
}
delete m_Bitmaps[i];
m_Bitmaps[i] = NULL;
}
// Load the bitmaps if defined
@ -91,16 +88,19 @@ void CMeterButton::Initialize()
{
Bitmap* bitmap = m_Image.GetImage();
m_W = bitmap->GetWidth();
m_H = bitmap->GetHeight();
int bitmapW = bitmap->GetWidth();
int bitmapH = bitmap->GetHeight();
m_W = bitmapW;
m_H = bitmapH;
if (m_H > m_W)
{
m_H = m_H / BUTTON_FRAMES;
m_H /= BUTTON_FRAMES;
}
else
{
m_W = m_W / BUTTON_FRAMES;
m_W /= BUTTON_FRAMES;
}
// Separate the frames
@ -110,7 +110,7 @@ void CMeterButton::Initialize()
Graphics graphics(&bitmapPart);
Rect r(0, 0, m_W, m_H);
if (m_H > m_W)
if (bitmapH > bitmapW)
{
graphics.DrawImage(bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel);
}
@ -269,13 +269,13 @@ bool CMeterButton::HitTest2(int px, int py, bool checkAlpha)
return false;
}
bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window)
bool CMeterButton::MouseUp(POINT pos, bool execute)
{
if (m_State == BUTTON_STATE_DOWN)
{
if (window && m_Clicked && m_Executable && HitTest2(pos.x, pos.y, true))
if (execute && m_Clicked && m_Focus && HitTest2(pos.x, pos.y, true))
{
Rainmeter->ExecuteCommand(m_Command.c_str(), window);
Rainmeter->ExecuteCommand(m_Command.c_str(), m_MeterWindow);
}
m_State = BUTTON_STATE_NORMAL;
m_Clicked = false;
@ -288,7 +288,7 @@ bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window)
bool CMeterButton::MouseDown(POINT pos)
{
if (m_Executable && HitTest2(pos.x, pos.y, true))
if (m_Focus && HitTest2(pos.x, pos.y, true))
{
m_State = BUTTON_STATE_DOWN;
m_Clicked = true;
@ -299,7 +299,7 @@ bool CMeterButton::MouseDown(POINT pos)
bool CMeterButton::MouseMove(POINT pos)
{
if (m_Clicked == true)
if (m_Clicked)
{
if (HitTest2(pos.x, pos.y, true))
{

View File

@ -37,11 +37,10 @@ public:
virtual void BindMeasure(const std::list<CMeasure*>& measures);
bool MouseMove(POINT pos);
bool MouseUp(POINT pos, CMeterWindow* window);
bool MouseUp(POINT pos, bool execute);
bool MouseDown(POINT pos);
void SetExecutable(bool exec) { m_Executable = exec; }
bool IsExecutable() { return m_Executable; }
void SetFocus(bool f) { m_Focus = f; }
private:
bool HitTest2(int px, int py, bool checkAlpha);
@ -54,7 +53,7 @@ private:
std::wstring m_Command; // Command to be executed
int m_State;
bool m_Clicked;
bool m_Executable;
bool m_Focus;
};
#endif

View File

@ -83,16 +83,11 @@ void CMeterHistogram::DisposeBuffer()
m_MeterPos = 0;
// Delete buffers
if (m_PrimaryValues)
{
delete [] m_PrimaryValues;
m_PrimaryValues = NULL;
}
if (m_SecondaryValues)
{
delete [] m_SecondaryValues;
m_SecondaryValues = NULL;
}
delete [] m_PrimaryValues;
m_PrimaryValues = NULL;
delete [] m_SecondaryValues;
m_SecondaryValues = NULL;
}
/*

View File

@ -185,9 +185,10 @@ bool CMeterImage::Update()
stringValues.push_back(val);
// Get the values for the other measures
for (size_t i = 0, isize = m_Measures.size(); i < isize; ++i)
std::vector<CMeasure*>::const_iterator iter = m_Measures.begin();
for ( ; iter != m_Measures.end(); ++iter)
{
stringValues.push_back(m_Measures[i]->GetStringValue(AUTOSCALE_OFF, 1, 0, false));
stringValues.push_back((*iter)->GetStringValue(AUTOSCALE_OFF, 1, 0, false));
}
m_ImageNameResult = m_ImageName;

View File

@ -484,9 +484,10 @@ bool CMeterString::Update()
if (m_Measure) stringValues.push_back(m_Measure->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
// Get the values for the other measures
for (size_t i = 0, isize = m_Measures.size(); i < isize; ++i)
std::vector<CMeasure*>::const_iterator iter = m_Measures.begin();
for ( ; iter != m_Measures.end(); ++iter)
{
stringValues.push_back(m_Measures[i]->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
stringValues.push_back((*iter)->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
}
// Create the text

View File

@ -189,8 +189,8 @@ CMeterWindow::~CMeterWindow()
delete (*i);
}
if (m_Background) delete m_Background;
if (m_DoubleBuffer) delete m_DoubleBuffer;
delete m_Background;
delete m_DoubleBuffer;
if (m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
if (m_BlurRegion) DeleteObject(m_BlurRegion);
@ -215,7 +215,8 @@ CMeterWindow::~CMeterWindow()
Result = UnregisterClass(METERWINDOW_CLASS_NAME, m_Rainmeter->GetInstance());
Sleep(100);
++counter;
} while(!Result && counter < 10);
}
while(!Result && counter < 10);
if (c_DwmInstance)
{
@ -367,7 +368,7 @@ void CMeterWindow::Refresh(bool init, bool all)
}
m_Meters.clear();
if (m_Background) delete m_Background;
delete m_Background;
m_Background = NULL;
m_BackgroundSize.cx = m_BackgroundSize.cy = 0;
@ -933,8 +934,8 @@ void CMeterWindow::RunBang(BANGCOMMAND bang, const WCHAR* arg)
{
args.erase(pos3, 1);
}
} while(pos3 != std::wstring::npos);
}
while(pos3 != std::wstring::npos);
pos3 = args.find(L' ');
if (pos3 != std::wstring::npos)
@ -2149,8 +2150,8 @@ bool CMeterWindow::ReadSkin()
WCHAR tmpName[64];
_snwprintf_s(tmpName, _TRUNCATE, L"BlurRegion%i", ++i);
blurRegion = m_Parser.ReadString(L"Rainmeter", tmpName, L"");
} while (!blurRegion.empty());
}
while (!blurRegion.empty());
}
else
{
@ -2208,8 +2209,8 @@ bool CMeterWindow::ReadSkin()
WCHAR tmpName[64];
_snwprintf_s(tmpName, _TRUNCATE, L"LocalFont%i", ++i);
localFont = m_Parser.ReadString(L"Rainmeter", tmpName, L"");
} while (!localFont.empty());
}
while (!localFont.empty());
}
// Create the meters and measures
@ -2218,18 +2219,17 @@ bool CMeterWindow::ReadSkin()
m_HasButtons = false;
// Get all the sections (i.e. different meters, measures and the other stuff)
std::vector<std::wstring> arraySections = m_Parser.GetSections();
for (size_t i = 0, isize = arraySections.size(); i < isize; ++i)
std::vector<std::wstring>::const_iterator iter = m_Parser.GetSections().begin();
for ( ; iter != m_Parser.GetSections().end(); ++iter)
{
const WCHAR* section = arraySections[i].c_str();
const WCHAR* section = (*iter).c_str();
if (_wcsicmp(L"Rainmeter", section) != 0 &&
_wcsicmp(L"Variables", section) != 0 &&
_wcsicmp(L"Metadata", section) != 0)
{
// Check if the item is a meter or a measure (or perhaps something else)
const std::wstring& measureName = m_Parser.ReadString(section, L"Measure", L"");
const std::wstring& measureName = m_Parser.ReadString(section, L"Measure", L"", false);
if (!measureName.empty())
{
// It's a measure
@ -2261,7 +2261,7 @@ bool CMeterWindow::ReadSkin()
continue;
}
const std::wstring& meterName = m_Parser.ReadString(section, L"Meter", L"");
const std::wstring& meterName = m_Parser.ReadString(section, L"Meter", L"", false);
if (!meterName.empty())
{
// It's a meter
@ -2410,11 +2410,8 @@ bool CMeterWindow::ResizeWindow(bool reset)
// Reset size (this is calculated below)
if (m_Background)
{
delete m_Background;
m_Background = NULL;
}
delete m_Background;
m_Background = NULL;
if ((m_BackgroundMode == BGMODE_IMAGE || m_BackgroundMode == BGMODE_SCALED_IMAGE || m_BackgroundMode == BGMODE_TILED_IMAGE) && !m_BackgroundName.empty())
{
@ -2644,6 +2641,8 @@ void CMeterWindow::CreateRegion(bool clear)
}
else
{
HRGN region = NULL;
// Set window region if needed
if (!m_BackgroundName.empty())
{
@ -2653,20 +2652,13 @@ void CMeterWindow::CreateRegion(bool clear)
m_DoubleBuffer->GetHBITMAP(Color(255,0,255), &background);
if (background)
{
HRGN region = BitmapToRegion(background, RGB(255,0,255), 0x101010);
SetWindowRgn(m_Window, region, TRUE);
region = BitmapToRegion(background, RGB(255,0,255), 0x101010);
DeleteObject(background);
}
else
{
SetWindowRgn(m_Window, NULL, TRUE);
}
}
else
{
SetWindowRgn(m_Window, NULL, TRUE);
}
}
SetWindowRgn(m_Window, region, !m_NativeTransparency);
}
}
@ -2697,7 +2689,7 @@ void CMeterWindow::Redraw()
if (cx != m_DIBSectionBufferW || cy != m_DIBSectionBufferH || m_DIBSectionBufferPixels == NULL)
{
if (m_DoubleBuffer) delete m_DoubleBuffer;
delete m_DoubleBuffer;
if (m_DIBSectionBuffer) DeleteObject(m_DIBSectionBuffer);
m_DIBSectionBufferPixels = NULL;
@ -2760,7 +2752,7 @@ void CMeterWindow::Redraw()
for ( ; j != m_Meters.end(); ++j)
{
const Matrix* matrix = (*j)->GetTransformationMatrix();
if (matrix && matrix->IsIdentity())
if (matrix && !matrix->IsIdentity())
{
// Change the world matrix
graphics.SetTransform(matrix);
@ -2962,7 +2954,7 @@ void CMeterWindow::Update(bool nodraw)
// If our option is to disable when in an RDP session, then check if in an RDP session.
// Only redraw if we are not in a remote session
if (!Rainmeter->GetDisableRDP() || !GetSystemMetrics(SM_REMOTESESSION))
if (!m_Rainmeter->GetDisableRDP() || !GetSystemMetrics(SM_REMOTESESSION))
{
Redraw();
}
@ -3334,10 +3326,9 @@ bool CMeterWindow::HitTest(int x, int y)
** HandleButtons
**
** Handles all buttons and cursor.
** Note that meterWindow parameter is used if proc is BUTTONPROC_UP.
**
*/
void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meterWindow)
void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, bool execute)
{
bool redraw = false;
bool drawCursor = false;
@ -3361,7 +3352,7 @@ void CMeterWindow::HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meter
break;
case BUTTONPROC_UP:
redraw |= button->MouseUp(pos, meterWindow);
redraw |= button->MouseUp(pos, execute);
break;
case BUTTONPROC_MOVE:
@ -3483,7 +3474,7 @@ LRESULT CMeterWindow::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
while (DoMoveAction(pos.x, pos.y, MOUSE_OVER)) ;
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
}
return 0;
@ -3508,7 +3499,7 @@ LRESULT CMeterWindow::OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam)
while (DoMoveAction(pos.x, pos.y, MOUSE_LEAVE)) ; // Leave all forcibly
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
}
return 0;
@ -3873,7 +3864,7 @@ LRESULT CMeterWindow::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
MapWindowPoints(NULL, m_Window, &pos, 1);
// Handle buttons
HandleButtons(pos, BUTTONPROC_UP, NULL); // redraw only
HandleButtons(pos, BUTTONPROC_UP, false); // redraw only
// Workaround for the system that the window size is changed incorrectly when the window is dragged over the upper side of the virtual screen
UpdateTransparency(m_TransparencyValue, false);
@ -3932,7 +3923,7 @@ LRESULT CMeterWindow::OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/
LRESULT CMeterWindow::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (m_WindowDraggable && !Rainmeter->GetDisableDragging())
if (m_WindowDraggable && !m_Rainmeter->GetDisableDragging())
{
POINT pos;
pos.x = (SHORT)LOWORD(lParam);
@ -4007,7 +3998,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara
}
// Snap to other windows
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
const std::map<std::wstring, CMeterWindow*>& windows = m_Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
for ( ; iter != windows.end(); ++iter)
{
@ -4190,7 +4181,7 @@ LRESULT CMeterWindow::OnLeftButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_DOWN, NULL);
HandleButtons(pos, BUTTONPROC_DOWN);
if (GetKeyState(VK_CONTROL) < 0 || // Ctrl is pressed, so only run default action
(!DoAction(pos.x, pos.y, MOUSE_LMB_DOWN, false) && m_WindowDraggable))
@ -4224,7 +4215,7 @@ LRESULT CMeterWindow::OnLeftButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_UP, this);
HandleButtons(pos, BUTTONPROC_UP);
DoAction(pos.x, pos.y, MOUSE_LMB_UP, false);
@ -4250,7 +4241,7 @@ LRESULT CMeterWindow::OnLeftButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM l
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_DOWN, NULL);
HandleButtons(pos, BUTTONPROC_DOWN);
if (!DoAction(pos.x, pos.y, MOUSE_LMB_DBLCLK, false))
{
@ -4279,7 +4270,7 @@ LRESULT CMeterWindow::OnRightButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
DoAction(pos.x, pos.y, MOUSE_RMB_DOWN, false);
@ -4299,7 +4290,7 @@ LRESULT CMeterWindow::OnRightButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
pos.y = (SHORT)HIWORD(lParam);
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
if (GetKeyState(VK_CONTROL) < 0 || // Ctrl is pressed, so only run default action
!DoAction(pos.x, pos.y, MOUSE_RMB_UP, false))
@ -4330,7 +4321,7 @@ LRESULT CMeterWindow::OnRightButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
if (!DoAction(pos.x, pos.y, MOUSE_RMB_DBLCLK, false))
{
@ -4359,7 +4350,7 @@ LRESULT CMeterWindow::OnMiddleButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
DoAction(pos.x, pos.y, MOUSE_MMB_DOWN, false);
@ -4385,7 +4376,7 @@ LRESULT CMeterWindow::OnMiddleButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
DoAction(pos.x, pos.y, MOUSE_MMB_UP, false);
@ -4411,7 +4402,7 @@ LRESULT CMeterWindow::OnMiddleButtonDoubleClick(UINT uMsg, WPARAM wParam, LPARAM
}
// Handle buttons
HandleButtons(pos, BUTTONPROC_MOVE, NULL);
HandleButtons(pos, BUTTONPROC_MOVE);
if (!DoAction(pos.x, pos.y, MOUSE_MMB_DBLCLK, false))
{
@ -4448,7 +4439,7 @@ LRESULT CMeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
POINT posc = {pos.x - rect.left, pos.y - rect.top};
// Handle buttons
HandleButtons(posc, BUTTONPROC_MOVE, NULL);
HandleButtons(posc, BUTTONPROC_MOVE);
// If RMB up or RMB down or double-click cause actions, do not show the menu!
if (!(GetKeyState(VK_CONTROL) < 0) && // Ctrl is pressed, so ignore any actions
@ -4682,18 +4673,12 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
{
if (!buttonFound)
{
if (!button->IsExecutable())
{
button->SetExecutable(true);
}
button->SetFocus(true);
buttonFound = true;
}
else
{
if (button->IsExecutable())
{
button->SetExecutable(false);
}
button->SetFocus(false);
}
}
}
@ -4729,10 +4714,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSE mouse)
CMeterButton* button = dynamic_cast<CMeterButton*>(*j);
if (button)
{
if (button->IsExecutable())
{
button->SetExecutable(false);
}
button->SetFocus(false);
}
}
@ -4977,7 +4959,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// Check that we're still alive
bool found = false;
const std::map<std::wstring, CMeterWindow*>& meters = Rainmeter->GetAllMeterWindows();
const std::map<std::wstring, CMeterWindow*>& meters = m_Rainmeter->GetAllMeterWindows();
std::map<std::wstring, CMeterWindow*>::const_iterator iter = meters.begin();
for ( ; iter != meters.end(); ++iter)
@ -5001,7 +4983,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
_wcsnicmp(L"PLAYSTOP", str.c_str(), 8) == 0)
{
// Audio commands are special cases.
Rainmeter->ExecuteCommand(str.c_str(), this);
m_Rainmeter->ExecuteCommand(str.c_str(), this);
return TRUE;
}
@ -5044,7 +5026,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
arg += m_SkinName;
arg += L"\"";
return Rainmeter->ExecuteBang(bang, arg, this);
return m_Rainmeter->ExecuteBang(bang, arg, this);
}
else
{

View File

@ -326,7 +326,7 @@ private:
void InitializeMeters();
void ShowWindowIfAppropriate();
HWND GetWindowFromPoint(POINT pos);
void HandleButtons(POINT pos, BUTTONPROC proc, CMeterWindow* meterWindow);
void HandleButtons(POINT pos, BUTTONPROC proc, bool execute = true);
void SetClickThrough(bool b);
void SetKeepOnScreen(bool b);
void SetWindowDraggable(bool b);

View File

@ -56,6 +56,8 @@ int Initialize(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpCmdLine)
}
catch (CError& error)
{
delete Rainmeter;
Rainmeter = NULL;
MessageBox(hWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
}
@ -70,11 +72,8 @@ int Initialize(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpCmdLine)
*/
void Quit()
{
if (Rainmeter)
{
delete Rainmeter;
Rainmeter = NULL;
}
delete Rainmeter;
Rainmeter = NULL;
}
/*
@ -787,7 +786,7 @@ CRainmeter::~CRainmeter()
{
DeleteMeterWindow(NULL, false); // This removes the window from the vector
if (m_TrayWindow) delete m_TrayWindow;
delete m_TrayWindow;
CSystem::Finalize();
@ -1578,7 +1577,8 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
++index;
}
}
} while (FindNextFile(hSearch, &fileData));
}
while (FindNextFile(hSearch, &fileData));
FindClose(hSearch);
@ -1650,7 +1650,8 @@ void CRainmeter::ScanForThemes(const std::wstring& path)
{
m_Themes.push_back(fileData.cFileName);
}
} while (FindNextFile(hSearch, &fileData));
}
while (FindNextFile(hSearch, &fileData));
FindClose(hSearch);
}
@ -3275,15 +3276,25 @@ void CRainmeter::ExpandEnvironmentVariables(std::wstring& strPath)
if (strPath.find(L'%') != std::wstring::npos)
{
// Expand the environment variables
DWORD ret = ExpandEnvironmentStrings(strPath.c_str(), buffer, bufSize);
if (ret != 0 && ret < bufSize)
do
{
strPath = buffer;
}
else
{
LogWithArgs(LOG_WARNING, L"Unable to expand environment strings in: %s", strPath.c_str());
DWORD ret = ExpandEnvironmentStrings(strPath.c_str(), buffer, bufSize);
if (ret == 0) // Error
{
LogWithArgs(LOG_WARNING, L"Unable to expand environment strings in: %s", strPath.c_str());
break;
}
if (ret <= bufSize) // Fits in the buffer
{
strPath = buffer;
break;
}
delete [] buffer;
bufSize = ret;
buffer = new WCHAR[bufSize];
}
while (true);
}
delete [] buffer;

View File

@ -414,7 +414,8 @@ void CSystem::SetMultiMonitorInfo()
}
}
++dwDevice;
} while (EnumDisplayDevices(NULL, dwDevice, &dd, 0));
}
while (EnumDisplayDevices(NULL, dwDevice, &dd, 0));
}
if (monitors.empty()) // Failed to enumerate the non-mirroring monitors
@ -653,7 +654,7 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
if (GetClassName(hwnd, className, 64) > 0 &&
wcscmp(className, METERWINDOW_CLASS_NAME) == 0 &&
Rainmeter && (Window = Rainmeter->GetMeterWindow(hwnd)))
(Window = Rainmeter->GetMeterWindow(hwnd)))
{
ZPOSITION zPos = Window->GetWindowZPosition();
if (zPos == ZPOSITION_ONDESKTOP || zPos == ZPOSITION_ONBOTTOM)
@ -696,47 +697,44 @@ BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lParam)
*/
void CSystem::ChangeZPosInOrder()
{
if (Rainmeter)
bool logging = Rainmeter->GetDebug() && DEBUG_VERBOSE;
std::vector<CMeterWindow*> windowsInZOrder;
if (logging) Log(LOG_DEBUG, L"1: ----- BEFORE -----");
// Retrieve the Rainmeter's meter windows in Z-order
EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder));
if (!c_ShowDesktop)
{
bool logging = Rainmeter->GetDebug() && DEBUG_VERBOSE;
std::vector<CMeterWindow*> windowsInZOrder;
if (logging) Log(LOG_DEBUG, L"1: ----- BEFORE -----");
// Retrieve the Rainmeter's meter windows in Z-order
EnumWindows(MyEnumWindowsProc, (LPARAM)(&windowsInZOrder));
if (!c_ShowDesktop)
{
// Reset ZPos in Z-order (Bottom)
std::vector<CMeterWindow*>::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end();
for ( ; iter != iterEnd; ++iter)
{
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONBOTTOM)
{
(*iter)->ChangeZPos(ZPOSITION_ONBOTTOM); // reset
}
}
}
// Reset ZPos in Z-order (On Desktop)
// Reset ZPos in Z-order (Bottom)
std::vector<CMeterWindow*>::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end();
for ( ; iter != iterEnd; ++iter)
{
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONDESKTOP)
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONBOTTOM)
{
(*iter)->ChangeZPos(ZPOSITION_ONDESKTOP); // reset
(*iter)->ChangeZPos(ZPOSITION_ONBOTTOM); // reset
}
}
}
if (logging)
// Reset ZPos in Z-order (On Desktop)
std::vector<CMeterWindow*>::const_iterator iter = windowsInZOrder.begin(), iterEnd = windowsInZOrder.end();
for ( ; iter != iterEnd; ++iter)
{
if ((*iter)->GetWindowZPosition() == ZPOSITION_ONDESKTOP)
{
Log(LOG_DEBUG, L"2: ----- AFTER -----");
// Log all windows in Z-order
EnumWindows(MyEnumWindowsProc, (LPARAM)NULL);
(*iter)->ChangeZPos(ZPOSITION_ONDESKTOP); // reset
}
}
if (logging)
{
Log(LOG_DEBUG, L"2: ----- AFTER -----");
// Log all windows in Z-order
EnumWindows(MyEnumWindowsProc, (LPARAM)NULL);
}
}
/*
@ -919,12 +917,12 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
case TIMER_NETSTATS:
CMeasureNet::UpdateIFTable();
CMeasureNet::UpdateStats();
if (Rainmeter) Rainmeter->WriteStats(false);
Rainmeter->WriteStats(false);
return 0;
case TIMER_DELETELATER:
if (Rainmeter) Rainmeter->ClearDeleteLaterList();
Rainmeter->ClearDeleteLaterList();
return 0;
}
break;
@ -943,15 +941,12 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
CConfigParser::UpdateWorkareaVariables();
}
if (Rainmeter)
// 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)
{
// 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)
{
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
}
PostMessage((*iter).second->GetWindow(), WM_DELAYED_MOVE, (WPARAM)uMsg, (LPARAM)0);
}
}
return 0;
@ -1218,11 +1213,8 @@ void CSystem::GetIniFileMappingList(std::vector<std::wstring>& iniFileMappings)
WCHAR buffer[MAX_PATH];
DWORD index = 0, cch = MAX_PATH;
while (true)
while ((ret = RegEnumKeyEx(hKey, index++, buffer, &cch, NULL, NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS)
{
ret = RegEnumKeyEx(hKey, index++, buffer, &cch, NULL, NULL, NULL, NULL);
if (ret == ERROR_NO_MORE_ITEMS) break;
if (ret == ERROR_SUCCESS)
{
iniFileMappings.push_back(buffer);
@ -1247,7 +1239,7 @@ std::wstring CSystem::GetTemporaryFile(const std::vector<std::wstring>& iniFileM
if (!iniFileMappings.empty())
{
std::wstring::size_type pos = iniFile.find_last_of(L'\\');
std::wstring::size_type pos = iniFile.find_last_of(L"\\/");
std::wstring filename;
if (pos != std::wstring::npos)
@ -1259,9 +1251,10 @@ std::wstring CSystem::GetTemporaryFile(const std::vector<std::wstring>& iniFileM
filename = iniFile;
}
for (size_t i = 0, isize = iniFileMappings.size(); i < isize; ++i)
std::vector<std::wstring>::const_iterator iter = iniFileMappings.begin();
for ( ; iter != iniFileMappings.end(); ++iter)
{
if (_wcsicmp(iniFileMappings[i].c_str(), filename.c_str()) == 0)
if (_wcsicmp((*iter).c_str(), filename.c_str()) == 0)
{
WCHAR buffer[MAX_PATH];
@ -1276,10 +1269,11 @@ std::wstring CSystem::GetTemporaryFile(const std::vector<std::wstring>& iniFileM
{
return temporary;
}
else // alternate is reserved or failed
else // temporary is reserved or failed
{
RemoveFile(temporary);
return tmp.empty() ? L"<>" : tmp;
if (tmp.empty()) tmp = L"<>";
return tmp;
}
}
else // failed

View File

@ -278,9 +278,10 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
delete m_Bitmap;
m_Bitmap = NULL;
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
std::vector<HICON>::const_iterator iter = m_TrayIcons.begin();
for ( ; iter != m_TrayIcons.end(); ++iter)
{
DestroyIcon(m_TrayIcons[i]);
DestroyIcon((*iter));
}
m_TrayIcons.clear();
@ -353,7 +354,8 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
if (hIcon) m_TrayIcons.push_back(hIcon);
if (imageName == buffer) break;
} while(hIcon != NULL);
}
while(hIcon != NULL);
}
}
@ -365,9 +367,9 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
Status status = m_Bitmap->GetLastStatus();
if (Ok != status)
{
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
delete m_Bitmap;
m_Bitmap = NULL;
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
}
}
}
@ -411,7 +413,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg)
{
case WM_COMMAND:
if (Rainmeter && tray)
if (tray)
{
if (wParam == ID_CONTEXT_MANAGE)
{
@ -574,7 +576,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
break;
case WM_QUERY_RAINMETER:
if (Rainmeter && IsWindow((HWND)lParam))
if (IsWindow((HWND)lParam))
{
COPYDATASTRUCT cds;
@ -760,7 +762,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 1;
case WM_COPYDATA:
if (Rainmeter)
{
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
@ -786,15 +787,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
break;
case WM_TRAY_DELAYED_REFRESH_ALL:
if (Rainmeter)
{
// Refresh all
Rainmeter->RefreshAll();
}
Rainmeter->RefreshAll();
return 0;
case WM_TRAY_DELAYED_EXECUTE:
if (Rainmeter && lParam)
if (lParam)
{
// Execute bang
WCHAR* bang = (WCHAR*)lParam;