From 0841328ea0972c117419b29e5bd3b806adc5f573 Mon Sep 17 00:00:00 2001 From: spx Date: Thu, 2 Jun 2011 01:54:05 +0000 Subject: [PATCH] Tweaks. --- Library/MeterWindow.cpp | 2 +- Library/Rainmeter.cpp | 57 ++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index b61f8e6d..08572bd7 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -4986,7 +4986,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam) if (!found) { Log(LOG_WARNING, L"Unable to send the !bang to a deactivated config."); - return 0; // This meterwindow has been deactivated + return TRUE; // This meterwindow has been deactivated } std::wstring str = (const WCHAR*)pCopyDataStruct->lpData; diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index 553a5881..a9f852f3 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -214,11 +214,14 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData) { static std::wstring result; - if (_sCommand == NULL) _sCommand = L""; + if (_sCommand == NULL || *_sCommand == L'\0') + { + return L"noop"; + } + if (_sData == NULL) _sData = L""; std::wstring sCommand = _sCommand; - std::wstring sData = _sData; std::transform(sCommand.begin(), sCommand.end(), sCommand.begin(), ::towlower); // Command GetConfig @@ -230,7 +233,7 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData) { // returns the config name, lookup by INI file - CMeterWindow *meterWindow = Rainmeter->GetMeterWindowByINI(sData); + CMeterWindow *meterWindow = Rainmeter->GetMeterWindowByINI(_sData); if (meterWindow) { result = L"\""; @@ -242,6 +245,30 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData) return L""; } + // Command GetWindow + // Data [the config name] + // Execution none + // Result the HWND to the specified config window if found, 'error' otherwise + if (sCommand == L"getwindow") + { + std::vector subStrings = CRainmeter::ParseString(_sData); + + if (subStrings.size() >= 1) + { + const std::wstring& config = subStrings[0]; + + CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config); + if (meterWindow) + { + WCHAR buf1[64]; + _snwprintf_s(buf1, _TRUNCATE, L"%lu", PtrToUlong(meterWindow->GetWindow())); + result = buf1; + return result.c_str(); + } + } + return L"error"; + } + // Command SkinAuthor // Data the config name // Execution none @@ -334,30 +361,6 @@ LPCTSTR PluginBridge(LPCTSTR _sCommand, LPCTSTR _sData) return L"error"; } - // Command GetWindow - // Data [the config name] - // Execution none - // Result the HWND to the specified config window if found, 'error' otherwise - if (sCommand == L"getwindow") - { - std::vector subStrings = CRainmeter::ParseString(_sData); - - if (subStrings.size() >= 1) - { - const std::wstring& config = subStrings[0]; - - CMeterWindow *meterWindow = Rainmeter->GetMeterWindow(config); - if (meterWindow) - { - TCHAR buf1[100]; - _snwprintf_s(buf1, _TRUNCATE, L"%lu", meterWindow->GetWindow()); - result = buf1; - return result.c_str(); - } - } - return L"error"; - } - return L"noop"; }