Code optimization.

This commit is contained in:
spx 2010-11-25 22:00:34 +00:00
parent 0e1486f0be
commit 999ab0bd18
17 changed files with 222 additions and 245 deletions

View File

@ -87,48 +87,30 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
if (pRainmeter)
{
SetBuiltInVariable(L"PROGRAMPATH", pRainmeter->GetPath());
// Extract volume path from program path
// E.g.:
// "C:\path\" to "C:"
// "\\server\share\" to "\\server\share"
// "\\server\C:\path\" to "\\server\C:"
const std::wstring& path = pRainmeter->GetPath();
std::wstring::size_type loc, loc2;
if ((loc = path.find_first_of(L':')) != std::wstring::npos)
{
SetBuiltInVariable(L"PROGRAMDRIVE", path.substr(0, loc + 1));
}
else if (path.length() >= 2 && (path[0] == L'\\' || path[0] == L'/') && (path[1] == L'\\' || path[1] == L'/'))
{
if ((loc = path.find_first_of(L"\\/", 2)) != std::wstring::npos)
{
if ((loc2 = path.find_first_of(L"\\/", loc + 1)) != std::wstring::npos || loc != (path.length() - 1))
{
loc = loc2;
}
}
SetBuiltInVariable(L"PROGRAMDRIVE", path.substr(0, loc));
}
SetBuiltInVariable(L"PROGRAMDRIVE", pRainmeter->GetDrive());
SetBuiltInVariable(L"SETTINGSPATH", pRainmeter->GetSettingsPath());
SetBuiltInVariable(L"SKINSPATH", pRainmeter->GetSkinPath());
SetBuiltInVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath());
SetBuiltInVariable(L"CURRENTPATH", CRainmeter::ExtractPath(m_Filename));
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetPath() + L"Addons\\");
SetBuiltInVariable(L"ADDONSPATH", pRainmeter->GetAddonPath());
SetBuiltInVariable(L"CRLF", L"\n");
if (meterWindow)
{
const std::wstring& config = meterWindow->GetSkinName();
std::wstring path = pRainmeter->GetSkinPath();
std::wstring::size_type loc;
if ((loc = config.find_first_of(L'\\')) != std::wstring::npos)
{
SetBuiltInVariable(L"ROOTCONFIGPATH", pRainmeter->GetSkinPath() + config.substr(0, loc + 1));
path += config.substr(0, loc + 1);
}
else
{
SetBuiltInVariable(L"ROOTCONFIGPATH", pRainmeter->GetSkinPath() + config + L"\\");
path += config;
path += L"\\";
}
SetBuiltInVariable(L"ROOTCONFIGPATH", path);
}
}
if (meterWindow)
@ -1126,7 +1108,10 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
std::vector<std::wstring>& array = (*iter).second;
array.push_back(strTmpKey);
}
m_Values[strTmpSection + L"::" + strTmpKey] = strValue;
strTmpSection += L"::";
strTmpSection += strTmpKey;
m_Values[strTmpSection] = strValue;
}
//==============================================================================
@ -1140,7 +1125,8 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
*/
const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault)
{
std::wstring strTmp(strSection + L"::" + strKey);
std::wstring strTmp(strSection + L"::");
strTmp += strKey;
std::transform(strTmp.begin(), strTmp.end(), strTmp.begin(), ::towlower);
stdext::hash_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(strTmp);

View File

@ -373,9 +373,7 @@ HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR sz
std::wstring dir = CRainmeter::ExtractPath(command);
SHELLEXECUTEINFO si;
memset(&si, 0, sizeof(si));
si.cbSize = sizeof(SHELLEXECUTEINFO);
SHELLEXECUTEINFO si = {sizeof(SHELLEXECUTEINFO)};
si.hwnd = Owner;
si.lpVerb = szVerb;
si.lpFile = command.c_str();

View File

@ -117,9 +117,9 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
pos = m_PluginName.rfind(L'\\');
if (pos != std::wstring::npos)
{
m_PluginName = L"..\\" + m_PluginName;
m_PluginName.insert(0, L"..\\");
}
m_PluginName = Rainmeter->GetPluginPath() + m_PluginName;
m_PluginName.insert(0, Rainmeter->GetPluginPath());
DWORD err = 0;
m_Plugin = CSystem::RmLoadLibrary(m_PluginName.c_str(), &err);
@ -151,8 +151,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
if (m_Plugin == NULL)
{
std::wstring error = L"Rainmeter plugin ";
error += m_PluginName;
std::wstring error = L"Rainmeter plugin " + m_PluginName;
error += L" not found!";
throw CError(error, __LINE__, __FILE__);
}
@ -169,8 +168,7 @@ void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
{
FreeLibrary(m_Plugin);
std::wstring error = L"Rainmeter plugin ";
error += m_PluginName;
std::wstring error = L"Rainmeter plugin " + m_PluginName;
error += L" doesn't export Update or GetString function!";
throw CError(error, __LINE__, __FILE__);
}

View File

@ -149,8 +149,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
}
else
{
std::wstring error = L"HKEY=";
error += keyname;
std::wstring error = L"HKEY=" + keyname;
error += L" is not valid in measure [";
error += m_Name;
error += L"].";

View File

@ -444,8 +444,7 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
// The meter is not bound to anything
if (m_MeasureName.empty())
{
std::wstring error = L"The meter [";
error += m_Name;
std::wstring error = L"The meter [" + m_Name;
error += L"] is not bound to anything!";
throw CError(error, __LINE__, __FILE__);
}
@ -462,8 +461,7 @@ void CMeter::BindMeasure(const std::list<CMeasure*>& measures)
}
// Error :)
std::wstring error = L"The meter [";
error += m_Name;
std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with [";
error += m_MeasureName;
error += L"]!";

View File

@ -108,7 +108,10 @@ void CMeterBar::ReadConfig(const WCHAR* section)
m_Color = parser.ReadColor(section, L"BarColor", Color::Green);
m_ImageName = parser.ReadString(section, L"BarImage", L"");
if (!m_ImageName.empty())
{
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
}
m_Border = parser.ReadInt(section, L"BarBorder", 0);
@ -126,8 +129,7 @@ void CMeterBar::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"BarOrientation=";
error += orientation;
std::wstring error = L"BarOrientation=" + orientation;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";

View File

@ -184,7 +184,10 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"BitmapImage", L"");
if (!m_ImageName.empty())
{
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
}
m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1);
m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0);
@ -211,8 +214,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"BitmapAlign=";
error += align;
std::wstring error = L"BitmapAlign=" + align;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";

View File

@ -170,7 +170,10 @@ void CMeterButton::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ButtonImage", L"");
if (!m_ImageName.empty())
{
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
}
m_Command = parser.ReadString(section, L"ButtonCommand", L"", false);

View File

@ -265,13 +265,22 @@ void CMeterHistogram::ReadConfig(const WCHAR* section)
}
m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L"");
if (!m_PrimaryImageName.empty())
{
m_PrimaryImageName = m_MeterWindow->MakePathAbsolute(m_PrimaryImageName);
}
m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L"");
if (!m_SecondaryImageName.empty())
{
m_SecondaryImageName = m_MeterWindow->MakePathAbsolute(m_SecondaryImageName);
}
m_BothImageName = parser.ReadString(section, L"BothImage", L"");
if (!m_BothImageName.empty())
{
m_BothImageName = m_MeterWindow->MakePathAbsolute(m_BothImageName);
}
m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0);
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);
@ -580,8 +589,7 @@ void CMeterHistogram::BindMeasure(const std::list<CMeasure*>& measures)
}
}
std::wstring error = L"The meter [";
error += m_Name;
std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with [";
error += m_SecondaryMeasureName;
error += L"]!";

View File

@ -419,7 +419,11 @@ void CMeterImage::ReadConfig(const WCHAR* section)
std::wstring oldImageName = m_ImageName;
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_ImageName = m_MeterWindow->MakePathAbsolute(m_Path + m_ImageName);
if (!m_ImageName.empty())
{
m_ImageName.insert(0, m_Path);
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
}
if (m_DynamicVariables)
{
@ -539,8 +543,7 @@ void CMeterImage::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"ImageFlip=";
error += flip;
std::wstring error = L"ImageFlip=" + flip;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";
@ -588,7 +591,8 @@ bool CMeterImage::Update()
std::wstring val = m_Measure->GetStringValue(false, 1, 0, false);
if (!val.empty())
{
val = m_MeterWindow->MakePathAbsolute(m_Path + val);
val.insert(0, m_Path);
val = m_MeterWindow->MakePathAbsolute(val);
if (val != m_ImageName)
{
m_ImageName = val;

View File

@ -397,8 +397,7 @@ void CMeterLine::BindMeasure(const std::list<CMeasure*>& measures)
if (i == measures.end())
{
std::wstring error = L"The meter [";
error += m_Name;
std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with [";
error += (*j);
error += L"]!";

View File

@ -99,7 +99,10 @@ void CMeterRotator::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ImageName", L"");
if (!m_ImageName.empty())
{
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
}
m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0);
m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0);

View File

@ -161,8 +161,7 @@ void CMeterString::Initialize()
// It couldn't find the font family: Log it.
if(Ok != status)
{
std::wstring error = L"Error: Couldn't load font family: ";
error += m_FontFace;
std::wstring error = L"Error: Couldn't load font family: " + m_FontFace;
LSLog(LOG_DEBUG, APPNAME, error.c_str());
delete m_FontFamily;
@ -230,8 +229,7 @@ void CMeterString::Initialize()
if (m_FontSize != 0)
{
std::wstring error = L"Unable to create font: ";
error += m_FontFace;
std::wstring error = L"Unable to create font: " + m_FontFace;
throw CError(error, __LINE__, __FILE__);
}
}
@ -333,8 +331,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"StringAlign=";
error += align;
std::wstring error = L"StringAlign=" + align;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";
@ -361,8 +358,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"StringCase=";
error += stringCase;
std::wstring error = L"StringCase=" + stringCase;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";
@ -389,8 +385,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"StringStyle=";
error += style;
std::wstring error = L"StringStyle=" + style;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";
@ -413,8 +408,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
}
else
{
std::wstring error = L"StringEffect=";
error += effect;
std::wstring error = L"StringEffect=" + effect;
error += L" is not valid in meter [";
error += m_Name;
error += L"].";
@ -656,8 +650,7 @@ void CMeterString::BindMeasure(const std::list<CMeasure*>& measures)
if (i == measures.end())
{
std::wstring error = L"The meter [";
error += m_Name;
std::wstring error = L"The meter [" + m_Name;
error += L"] cannot be bound with [";
error += (*j);
error += L"]!";
@ -698,18 +691,21 @@ void CMeterString::FreeFontCache()
*/
std::wstring CMeterString::FontPropertiesToString(FontFamily* fontFamily, REAL size, FontStyle style)
{
std::wstringstream stream;
stream << size << L"-" << (int)style;
WCHAR ids[128] = {0};
swprintf(ids, L"%.1f-%i", size, (int)style);
if (fontFamily)
{
WCHAR familyName[LF_FACESIZE];
if (Ok == fontFamily->GetFamilyName(familyName))
{
return std::wstring(familyName) + L"-" + stream.str();
std::wstring prop = familyName;
prop += L"-";
prop += ids;
return prop;
}
}
return stream.str();
return ids;
}
/*

View File

@ -184,14 +184,12 @@ CMeterWindow::~CMeterWindow()
*/
int CMeterWindow::Initialize(CRainmeter& Rainmeter)
{
WNDCLASSEX wc;
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
m_Rainmeter = &Rainmeter;
// Register the windowclass
memset(&wc, 0, sizeof(WNDCLASSEX));
wc.style = CS_NOCLOSE | CS_DBLCLKS;
wc.cbSize = sizeof(WNDCLASSEX);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpfnWndProc = WndProc;
wc.hInstance = m_Rainmeter->GetInstance();
@ -295,7 +293,8 @@ void CMeterWindow::Refresh(bool init, bool all)
m_Rainmeter->SetCurrentParser(&m_Parser);
std::wstring dbg = L"Refreshing skin \"" + m_SkinName;
dbg += L"\\" + m_SkinIniFile;
dbg += L"\\";
dbg += m_SkinIniFile;
dbg += L"\"";
LSLog(LOG_DEBUG, APPNAME, dbg.c_str());
@ -1266,15 +1265,8 @@ void CMeterWindow::WindowToScreen()
{
index = index + 1;
index2 = m_WindowX.find_first_not_of(L"0123456789", index);
std::wstring screenStr;
if (index2 != std::wstring::npos)
{
screenStr = m_WindowX.substr(index, index2 - index);
}
else
{
screenStr = m_WindowX.substr(index);
}
std::wstring screenStr = m_WindowX.substr(index, (index2 != std::wstring::npos) ? index2 - index : std::wstring::npos);
if (!screenStr.empty())
{
int screenIndex = _wtoi(screenStr.c_str());
@ -1335,15 +1327,8 @@ void CMeterWindow::WindowToScreen()
{
index = index + 1;
index2 = m_WindowY.find_first_not_of(L"0123456789", index);
std::wstring screenStr;
if (index2 != std::wstring::npos)
{
screenStr = m_WindowY.substr(index, index2 - index);
}
else
{
screenStr = m_WindowY.substr(index);
}
std::wstring screenStr = m_WindowY.substr(index, (index2 != std::wstring::npos) ? index2 - index : std::wstring::npos);
if (!screenStr.empty())
{
int screenIndex = _wtoi(screenStr.c_str());
@ -1524,7 +1509,7 @@ void CMeterWindow::ScreenToWindow()
*/
void CMeterWindow::ReadConfig()
{
std::wstring iniFile = m_Rainmeter->GetIniFile();
const std::wstring& iniFile = m_Rainmeter->GetIniFile();
const WCHAR* section = L"Rainmeter";
// Reset settings to the default value
@ -1651,7 +1636,7 @@ void CMeterWindow::ReadConfig()
void CMeterWindow::WriteConfig()
{
WCHAR buffer[32];
std::wstring iniFile = m_Rainmeter->GetIniFile();
const std::wstring& iniFile = m_Rainmeter->GetIniFile();
const WCHAR* section = m_SkinName.c_str();
if(!iniFile.empty())
@ -1699,16 +1684,14 @@ void CMeterWindow::WriteConfig()
*/
bool CMeterWindow::ReadSkin()
{
std::wstring iniFile = m_SkinPath;
iniFile += m_SkinName;
std::wstring iniFile = m_SkinPath + m_SkinName;
iniFile += L"\\";
iniFile += m_SkinIniFile;
// Verify whether the file exists
if (_waccess(iniFile.c_str(), 0) == -1)
{
std::wstring message = L"Unable to refresh skin \"";
message += m_SkinName;
std::wstring message = L"Unable to refresh skin \"" + m_SkinName;
message += L"\\";
message += m_SkinIniFile;
message += L"\": Ini-file not found.";
@ -1742,8 +1725,7 @@ bool CMeterWindow::ReadSkin()
wsprintf(buffer, L"%i.%i", appVersion / 1000000, (appVersion / 1000) % 1000);
}
std::wstring text = L"The skin \"";
text += m_SkinName;
std::wstring text = L"The skin \"" + m_SkinName;
text += L"\\";
text += m_SkinIniFile;
text += L"\" needs Rainmeter ";
@ -1835,8 +1817,7 @@ bool CMeterWindow::ReadSkin()
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
if(nResults != Ok)
{
std::wstring error = L"Error: Couldn't load font file: ";
error += localFont;
std::wstring error = L"Error: Couldn't load font file: " + localFont;
LSLog(LOG_DEBUG, APPNAME, error.c_str());
}
}
@ -1879,8 +1860,7 @@ bool CMeterWindow::ReadSkin()
// The font file wasn't found anywhere, log the error
if(nResults != Ok)
{
std::wstring error = L"Error: Couldn't load font file: ";
error += localFont;
std::wstring error = L"Error: Couldn't load font file: " + localFont;
LSLog(LOG_DEBUG, APPNAME, error.c_str());
}
}
@ -1997,8 +1977,7 @@ bool CMeterWindow::ReadSkin()
if (m_Meters.empty())
{
std::wstring text = L"The skin \"";
text += m_SkinName;
std::wstring text = L"The skin \"" + m_SkinName;
text += L"\\";
text += m_SkinIniFile;
if (m_Measures.empty())
@ -3109,9 +3088,13 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if(wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
{
std::wstring command = m_Rainmeter->GetConfigEditor();
std::wstring command = m_Rainmeter->GetConfigEditor() + L" \"";
command += m_SkinPath;
command += L"\\";
command += m_SkinName;
command += L"\\";
command += m_SkinIniFile;
command += L"\"";
command += m_SkinPath + L"\\" + m_SkinName + L"\\" + m_SkinIniFile + L"\"";
// If the skins are in the program folder start the editor as admin
if (m_Rainmeter->GetPath() + L"Skins\\" == m_Rainmeter->GetSkinPath())
@ -3125,8 +3108,9 @@ LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
else if(wParam == ID_CONTEXT_SKINMENU_OPENSKINSFOLDER)
{
std::wstring command = L"\"";
command += m_SkinPath + L"\\" + m_SkinName;
std::wstring command = L"\"" + m_SkinPath;
command += L"\\";
command += m_SkinName;
command += L"\"";
LSExecute(NULL, command.c_str(), SW_SHOWNORMAL);
}

View File

@ -1302,7 +1302,8 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
if (c_CmdLine.empty())
{
m_IniFile = m_Path + L"Rainmeter.ini";
m_IniFile = m_Path;
m_IniFile += L"Rainmeter.ini";
// If the ini file doesn't exist in the program folder store it to the %APPDATA% instead so that things work better in Vista/Win7
if (_waccess(m_IniFile.c_str(), 0) == -1)
@ -1382,9 +1383,10 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
StartLogging();
}
m_PluginPath = tmpName;
m_PluginPath = m_AddonPath = m_SkinPath = m_Path;
m_PluginPath += L"Plugins\\";
m_SkinPath = m_Path + L"Skins\\";
m_AddonPath += L"Addons\\";
m_SkinPath += L"Skins\\";
// Read the skin folder from the ini file
WCHAR tmpSz[MAX_LINE_LENGTH];
@ -1404,14 +1406,13 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
m_SkinPath = szPath;
m_SkinPath += L"\\Rainmeter";
CreateDirectory(m_SkinPath.c_str(), NULL);
m_SkinPath += L"\\Skins";
m_SkinPath += L"\\Skins\\";
DWORD result = CreateDirectory(m_SkinPath.c_str(), NULL);
m_SkinPath += L"\\";
if (result != 0)
{
// The folder was created successfully which means that it wasn't available yet.
// Copy the default skin to the Skins folder
std::wstring strFrom(m_Path + L"Skins\\" + L"*.*");
std::wstring strFrom(m_Path + L"Skins\\*.*");
std::wstring strTo(m_SkinPath);
CSystem::CopyFiles(strFrom, strTo);
@ -1420,10 +1421,9 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
CSystem::RemoveFile(strNote);
// Copy also the themes to the %APPDATA%
strFrom = std::wstring(m_Path + L"Themes\\" + L"*.*");
strTo = std::wstring(GetSettingsPath() + L"Themes");
strFrom = std::wstring(m_Path + L"Themes\\*.*");
strTo = std::wstring(GetSettingsPath() + L"Themes\\");
CreateDirectory(strTo.c_str(), NULL);
strTo += L"\\";
CSystem::CopyFiles(strFrom, strTo);
}
}
@ -1469,6 +1469,29 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
DebugLog(L"SkinPath: %s", m_SkinPath.c_str());
DebugLog(L"PluginPath: %s", m_PluginPath.c_str());
// Extract volume path from program path
// E.g.:
// "C:\path\" to "C:"
// "\\server\share\" to "\\server\share"
// "\\server\C:\path\" to "\\server\C:"
std::wstring::size_type loc;
if ((loc = m_Path.find_first_of(L':')) != std::wstring::npos)
{
m_Drive = m_Path.substr(0, loc + 1);
}
else if (m_Path.length() >= 2 && (m_Path[0] == L'\\' || m_Path[0] == L'/') && (m_Path[1] == L'\\' || m_Path[1] == L'/'))
{
if ((loc = m_Path.find_first_of(L"\\/", 2)) != std::wstring::npos)
{
std::wstring::size_type loc2;
if ((loc2 = m_Path.find_first_of(L"\\/", loc + 1)) != std::wstring::npos || loc != (m_Path.length() - 1))
{
loc = loc2;
}
}
m_Drive = m_Path.substr(0, loc);
}
// Test that the Rainmeter.ini file is writable
TestSettingsFile(bDefaultIniLocation);
@ -1622,8 +1645,10 @@ void CRainmeter::CheckSkinVersions()
// DebugLog(L"%s", menu[i].name.c_str());
// Read the version files
std::wstring strNewVersionFile = strMainSkinsPath + menu[i].name + L"\\version";
std::wstring strCurrentVersionFile = m_SkinPath + menu[i].name + L"\\version";
std::wstring strNewVersionFile = strMainSkinsPath + menu[i].name;
strNewVersionFile += L"\\version";
std::wstring strCurrentVersionFile = m_SkinPath + menu[i].name;
strCurrentVersionFile += L"\\version";
std::string strVersion;
std::wstring strVersionNew;
@ -1664,13 +1689,13 @@ void CRainmeter::CheckSkinVersions()
std::wstring strSkinPath = m_SkinPath + menu[i].name;
if (_wstat(strSkinPath.c_str(), &s) == 0)
{
std::wstring strMessage = L"A new version of config \"" + menu[i].name + L"\" is available.\n\n";
strMessage += L"New version: " + (strVersionNew.empty() ? L"Unknown" : strVersionNew) + L"\n";
strMessage += L"Current version: " + (strVersionCurrent.empty() ? L"Unknown" : strVersionCurrent) + L"\n";
strMessage += L"\n";
strMessage += L"Do you want to upgrade?";
strMessage += L"\n\n";
strMessage += L"(If you select 'Yes' your current config\nwill be moved into the 'Backup' folder)";
std::wstring strMessage = L"A new version of config \"" + menu[i].name;
strMessage += L"\" is available.\n\nNew version: ";
strMessage += strVersionNew.empty() ? L"Unknown" : strVersionNew;
strMessage += L"\nCurrent version: ";
strMessage += strVersionCurrent.empty() ? L"Unknown" : strVersionCurrent;
strMessage += L"\n\nDo you want to upgrade?\n\n"
L"(If you select 'Yes' your current config\nwill be moved into the 'Backup' folder)";
if (IDYES == MessageBox(NULL, strMessage.c_str(), APPNAME, MB_YESNO | MB_ICONQUESTION))
{
@ -1680,7 +1705,10 @@ void CRainmeter::CheckSkinVersions()
// Check for illegal characters from the version number
if (strVersionCurrent.find_first_of(L"\\/\"*:?<>|") == std::wstring::npos)
{
std::wstring strTarget = m_SkinPath + L"Backup\\" + menu[i].name + L"-" + strVersionCurrent;
std::wstring strTarget = m_SkinPath + L"Backup\\";
strTarget += menu[i].name;
strTarget += L"-";
strTarget += strVersionCurrent;
if (CSystem::CopyFiles(m_SkinPath + menu[i].name, strTarget, true)) // Move the folder to "backup"
{
// Upgrade the skin
@ -1710,8 +1738,9 @@ void CRainmeter::CheckSkinVersions()
}
else
{
std::wstring strMessage = L"A new version of config \"" + menu[i].name + L"\" is available\n";
strMessage += L"Do you want to add it to your skin and themes libraries?";
std::wstring strMessage = L"A new version of config \"" + menu[i].name;
strMessage += L"\" is available\n"
L"Do you want to add it to your skin and themes libraries?";
if (IDYES == MessageBox(NULL, strMessage.c_str(), APPNAME, MB_YESNO | MB_ICONQUESTION))
{
CSystem::CopyFiles(strMainSkinsPath + menu[i].name, m_SkinPath);
@ -1829,15 +1858,13 @@ void CRainmeter::ActivateConfig(int configIndex, int iniIndex)
}
// Verify whether the ini-file exists
std::wstring skinIniPath = skinPath;
skinIniPath += skinConfig;
std::wstring skinIniPath = skinPath + skinConfig;
skinIniPath += L"\\";
skinIniPath += skinIniFile;
if (_waccess(skinIniPath.c_str(), 0) == -1)
{
std::wstring message = L"Unable to activate skin \"";
message += skinConfig;
std::wstring message = L"Unable to activate skin \"" + skinConfig;
message += L"\\";
message += skinIniFile;
message += L"\": Ini-file not found.";
@ -2221,7 +2248,8 @@ int CRainmeter::ScanForConfigsRecursive(const std::wstring& path, std::wstring b
}
// Scan for folders
std::wstring files = path + base + L"*";
std::wstring files = path + base;
files += L"*";
hSearch = FindFirstFile(files.c_str(), &fileData);
do
{
@ -2561,8 +2589,7 @@ BOOL CRainmeter::ExecuteBang(const std::wstring& bang, const std::wstring& arg,
}
else
{
std::wstring error = L"Unknown !bang: ";
error += bang;
std::wstring error = L"Unknown !bang: " + bang;
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
return FALSE;
}
@ -2734,8 +2761,6 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
// Read Logging settings
m_Logging = 0!=parser.ReadInt(L"Rainmeter", L"Logging", 0);
m_DisableDrag = 0!=parser.ReadInt(L"Rainmeter", L"DisableDrag", 0);
m_DisableRDP = 0!=parser.ReadInt(L"Rainmeter", L"DisableRDP", 0);
c_Debug = 0!=parser.ReadInt(L"Rainmeter", L"Debug", 0);
if (m_Logging)
@ -2751,6 +2776,9 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
c_GlobalConfig.netInSpeed = parser.ReadFloat(L"Rainmeter", L"NetInSpeed", 0.0);
c_GlobalConfig.netOutSpeed = parser.ReadFloat(L"Rainmeter", L"NetOutSpeed", 0.0);
m_DisableDrag = 0!=parser.ReadInt(L"Rainmeter", L"DisableDrag", 0);
m_DisableRDP = 0!=parser.ReadInt(L"Rainmeter", L"DisableRDP", 0);
m_ConfigEditor = parser.ReadString(L"Rainmeter", L"ConfigEditor", L"");
if (m_ConfigEditor.empty())
{
@ -2859,7 +2887,10 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
{
if (!SetActiveConfig(skinName, skinIni))
{
std::wstring error = L"The selected skin (L" + skinName + L"\\" + skinIni + L") cannot be found.";
std::wstring error = L"The selected skin (L" + skinName;
error += L"\\";
error += skinIni;
error += L") cannot be found.";
MessageBox(NULL, error.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
}
return;
@ -2967,8 +2998,7 @@ void CRainmeter::RefreshAll()
{
DeactivateConfig(mw, i);
std::wstring message = L"Unable to refresh skin \"";
message += skinConfig;
std::wstring message = L"Unable to refresh skin \"" + skinConfig;
message += L"\\";
message += skinIniFile;
message += L"\": Ini-file not found.";
@ -2985,8 +3015,7 @@ void CRainmeter::RefreshAll()
{
DeactivateConfig(mw, -2); // -2 = Deactivate the config forcibly
std::wstring message = L"Unable to refresh config \"";
message += skinConfig;
std::wstring message = L"Unable to refresh config \"" + skinConfig;
message += L"\": Config not found.";
LSLog(LOG_DEBUG, APPNAME, message.c_str());
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
@ -3693,8 +3722,7 @@ void CRainmeter::StartLogging()
ResetLoggingFlag(); // Re-enable logging
SetLogging(true);
std::wstring message = L"Log file created at: ";
message += m_LogFile;
std::wstring message = L"Log file created at: " + m_LogFile;
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONINFORMATION);
}
else
@ -3703,8 +3731,7 @@ void CRainmeter::StartLogging()
SetLogging(false);
ResetLoggingFlag();
std::wstring message = L"Unable to create log file: ";
message += m_LogFile;
std::wstring message = L"Unable to create log file: " + m_LogFile;
MessageBox(NULL, message.c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
}
}
@ -3724,9 +3751,8 @@ void CRainmeter::DeleteLogFile()
// Check if the file exists
if (_waccess(m_LogFile.c_str(), 0) != -1)
{
std::wstring message = L"Do you want to delete the following log file?\n";
message += m_LogFile;
int res = MessageBox(NULL, message.c_str(), L"Rainmeter", MB_YESNO | MB_TOPMOST | MB_ICONQUESTION);
std::wstring message = L"Do you want to delete the following log file?\n" + m_LogFile;
int res = MessageBox(NULL, message.c_str(), APPNAME, MB_YESNO | MB_TOPMOST | MB_ICONQUESTION);
if (res == IDYES)
{
// Disable logging
@ -3785,8 +3811,8 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
{
LSLog(LOG_DEBUG, APPNAME, L"The Rainmeter.ini file is NOT writable.");
std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n";
error += L"application will not be able to save any settings permanently.\n\n";
std::wstring error = L"The Rainmeter.ini file is not writable. This means that the\n"
L"application will not be able to save any settings permanently.\n\n";
if (!bDefaultIniLocation)
{
@ -3797,16 +3823,16 @@ void CRainmeter::TestSettingsFile(bool bDefaultIniLocation)
error += m_IniFile;
error += L"\n\nto\n\n";
error += strTarget;
error += L"\n\nAlternatively you can simply remove the file and\n";
error += L"it will be automatically recreated in the correct location\n";
error += L"when Rainmeter is restarted the next time (you\'ll lose your\n";
error += L"current settings though).\n";
error += L"\n\nAlternatively you can simply remove the file and\n"
L"it will be automatically recreated in the correct location\n"
L"when Rainmeter is restarted the next time (you\'ll lose your\n"
L"current settings though).\n";
}
else
{
error += L"Make sure that the settings file is not set as read-only and\n";
error += L"that it is located in a folder where you have write permissions.\n\n";
error += L"The settings file is located at:\n";
error += L"Make sure that the settings file is not set as read-only and\n"
L"that it is located in a folder where you have write permissions.\n\n"
L"The settings file is located at:\n";
error += m_IniFile;
}

View File

@ -161,8 +161,11 @@ public:
const std::wstring& GetLogFile() { return m_LogFile; }
const std::wstring& GetSkinPath() { return m_SkinPath; }
const std::wstring& GetPluginPath() { return m_PluginPath; }
const std::wstring& GetAddonPath() { return m_AddonPath; }
std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); }
const std::wstring& GetDrive() { return m_Drive; }
const std::wstring& GetConfigEditor() { return m_ConfigEditor; }
const std::wstring& GetLogViewer() { return m_LogViewer; }
const std::wstring& GetStatsDate() { return m_StatsDate; }
@ -263,6 +266,9 @@ private:
std::wstring m_LogFile; // The log file
std::wstring m_SkinPath; // Path to the folder where the skins are
std::wstring m_PluginPath; // Path to the folder where the plugins are
std::wstring m_AddonPath; // Path to the folder where the addons are
std::wstring m_Drive;
std::wstring m_StatsDate; // The date when stats gathering started

View File

@ -107,7 +107,6 @@ CTrayWindow::~CTrayWindow()
BOOL CTrayWindow::AddTrayIcon()
{
BOOL res = FALSE;
NOTIFYICONDATA tnid;
if (m_TrayIcon)
{
@ -119,7 +118,7 @@ BOOL CTrayWindow::AddTrayIcon()
if (m_TrayIcon)
{
tnid.cbSize = sizeof(NOTIFYICONDATA);
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY;
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
@ -138,9 +137,7 @@ BOOL CTrayWindow::RemoveTrayIcon()
if (m_TrayIcon)
{
NOTIFYICONDATA tnid;
tnid.cbSize = sizeof(NOTIFYICONDATA);
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY;
tnid.uFlags = 0;
@ -157,7 +154,6 @@ BOOL CTrayWindow::RemoveTrayIcon()
BOOL CTrayWindow::ModifyTrayIcon(double value)
{
BOOL res = FALSE;
NOTIFYICONDATA tnid;
if (m_TrayIcon)
{
@ -167,7 +163,7 @@ BOOL CTrayWindow::ModifyTrayIcon(double value)
m_TrayIcon = CreateTrayIcon(value);
tnid.cbSize = sizeof(NOTIFYICONDATA);
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY;
tnid.uFlags = NIF_ICON;
@ -182,19 +178,16 @@ BOOL CTrayWindow::ShowBalloonHelp()
{
BOOL res = FALSE;
NOTIFYICONDATA nid;
memset(&nid, 0, sizeof(NOTIFYICONDATA));
nid.hWnd = m_Window;
nid.uID = IDI_TRAY;
nid.cbSize=sizeof(NOTIFYICONDATA);
nid.uFlags = NIF_INFO;
nid.uTimeout = 30000;
nid.dwInfoFlags = 4; // NIIF_USER;
nid.hIcon = LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
wcscpy(nid.szInfo, L"There aren't any configs active at the moment. Open the context menu from Rainmeter's tray icon and select a config you want to use.");
wcscpy(nid.szInfoTitle, L"Rainmeter");
res = Shell_NotifyIcon(NIM_MODIFY, &nid);
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
tnid.hWnd = m_Window;
tnid.uID = IDI_TRAY;
tnid.uFlags = NIF_INFO;
tnid.uTimeout = 30000;
tnid.dwInfoFlags = 4; // NIIF_USER;
tnid.hIcon = LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
wcscpy(tnid.szInfo, L"There aren't any configs active at the moment. Open the context menu from Rainmeter's tray icon and select a config you want to use.");
wcscpy(tnid.szInfoTitle, L"Rainmeter");
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
return res;
}
@ -334,7 +327,7 @@ void CTrayWindow::ReadConfig(CConfigParser& parser)
// Load the bitmaps if defined
if (!imageName.empty())
{
imageName = Rainmeter->GetSkinPath() + imageName;
imageName.insert(0, Rainmeter->GetSkinPath());
if (imageName.size() > 3)
{
std::wstring extension = imageName.substr(imageName.size() - 3);
@ -425,7 +418,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
else if(wParam == ID_CONTEXT_SHOWLOGFILE)
{
// Check if the file exists
std::wstring log = Rainmeter->GetLogFile();
const std::wstring& log = Rainmeter->GetLogFile();
if (_waccess(log.c_str(), 0) != -1)
{
std::wstring command = Rainmeter->GetLogViewer();
@ -455,22 +448,21 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == ID_CONTEXT_EDITCONFIG)
{
std::wstring command = Rainmeter->GetConfigEditor();
command += L" \"";
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)
{
std::wstring command = L"\"" + Rainmeter->GetPath();
command += L"\\Addons\\RainThemes\\RainThemes.exe\"";
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)
{
std::wstring command = L"\"" + Rainmeter->GetPath();
command += L"\\Addons\\RainBrowser\\RainBrowser.exe\"";
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)
@ -480,8 +472,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == ID_CONTEXT_OPENSKINSFOLDER)
{
std::wstring command = L"\"";
command += Rainmeter->GetSkinPath();
std::wstring command = L"\"" + Rainmeter->GetSkinPath();
command += L"\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
}
@ -492,8 +483,8 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
if (pos >= 0 && pos < (int)themes.size())
{
std::wstring command = L"\"" + Rainmeter->GetPath();
command += L"\\Addons\\RainThemes\\RainThemes.exe\" /load \"";
std::wstring command = L"\"" + Rainmeter->GetAddonPath();
command += L"RainThemes\\RainThemes.exe\" /load \"";
command += themes[pos];
command += L"\"";
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
@ -607,11 +598,11 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_QUERY_RAINMETER:
if (Rainmeter && IsWindow((HWND)lParam))
{
COPYDATASTRUCT cds;
if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
{
std::wstring path = Rainmeter->GetSkinPath();
COPYDATASTRUCT cds;
const std::wstring& path = Rainmeter->GetSkinPath();
cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
@ -625,8 +616,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{
std::wstring path = Rainmeter->GetSettingsPath();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_SETTINGS_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) path.c_str();
@ -637,9 +626,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
{
std::wstring path = Rainmeter->GetPluginPath();
COPYDATASTRUCT cds;
const std::wstring& path = Rainmeter->GetPluginPath();
cds.dwData = RAINMETER_QUERY_ID_PLUGINS_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
@ -651,9 +638,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
{
std::wstring path = Rainmeter->GetPath();
COPYDATASTRUCT cds;
const std::wstring& path = Rainmeter->GetPath();
cds.dwData = RAINMETER_QUERY_ID_PROGRAM_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
@ -665,9 +650,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_LOG_PATH)
{
std::wstring path = Rainmeter->GetLogFile();
COPYDATASTRUCT cds;
const std::wstring& path = Rainmeter->GetLogFile();
cds.dwData = RAINMETER_QUERY_ID_LOG_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
@ -679,9 +662,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
{
std::wstring editor = Rainmeter->GetConfigEditor();
COPYDATASTRUCT cds;
const std::wstring& editor = Rainmeter->GetConfigEditor();
cds.dwData = RAINMETER_QUERY_ID_CONFIG_EDITOR;
cds.cbData = (editor.size() + 1) * sizeof(wchar_t);
@ -695,8 +676,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
{
std::wstring commandline = Rainmeter->GetCommandLine();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_COMMAND_LINE;
cds.cbData = (commandline.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) commandline.c_str();
@ -723,9 +702,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_STATS_DATE)
{
std::wstring date = Rainmeter->GetStatsDate();
COPYDATASTRUCT cds;
const std::wstring& date = Rainmeter->GetStatsDate();
cds.dwData = RAINMETER_QUERY_ID_STATS_DATE;
cds.cbData = (date.size() + 1) * sizeof(wchar_t);
@ -737,9 +714,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
{
std::wstring tray = Rainmeter->GetTrayExecuteL();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteL();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_L;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
@ -751,9 +726,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
{
std::wstring tray = Rainmeter->GetTrayExecuteR();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteR();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_R;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
@ -765,9 +738,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
{
std::wstring tray = Rainmeter->GetTrayExecuteM();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteM();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_M;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
@ -779,9 +750,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
{
std::wstring tray = Rainmeter->GetTrayExecuteDL();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteDL();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DL;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
@ -793,9 +762,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
{
std::wstring tray = Rainmeter->GetTrayExecuteDR();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteDR();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DR;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
@ -807,9 +774,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
{
std::wstring tray = Rainmeter->GetTrayExecuteDM();
COPYDATASTRUCT cds;
const std::wstring& tray = Rainmeter->GetTrayExecuteDM();
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DM;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);