diff --git a/Library/Library.vcproj b/Library/Library.vcproj index e2887ab0..58d81dc6 100644 --- a/Library/Library.vcproj +++ b/Library/Library.vcproj @@ -2873,16 +2873,20 @@ RelativePath="Rainmeter.h" > + + dwData : QUERY ID (RAINMETER_QUERY_ID_XXXXX) + * COPYDATASTRUCT->lpData : requested string in wide char + * COPYDATASTRUCT->cbData : size of lpData + +----- +#include +#include +#include "RainmeterQuery.h" + +void QueryRainmeterSkinsPath(HWND hWndSelf) +{ + HWND hWndRainmeter = FindWindow(RAINMETER_QUERY_WINDOW_TITLE, RAINMETER_QUERY_WINDOW_CLASS); + if (hWndRainmeter) + { + PostMessage(hWndRainmeter, WM_QUERY_RAINMETER, RAINMETER_QUERY_ID_SKINS_PATH, (LPARAM)hWndSelf); + } +} + +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_COPYDATA: + { + COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lParam; + + // Copy ID and string to local + DWORD id = cds->dwData; // contains QUERY ID (RAINMETER_QUERY_ID_XXXXX) + std::wstring string = (WCHAR*)cds->lpData; // contains requested string in wide char + + // + ... + } + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} +----- +*/ + +#ifndef __RAINMETER_QUERY_H__ +#define __RAINMETER_QUERY_H__ + +#include + +#define RAINMETER_QUERY_WINDOW_NAME TEXT("RainmeterTrayClass") +#define RAINMETER_QUERY_CLASS_NAME NULL + +#define WM_QUERY_RAINMETER WM_APP + 1000 + +// QUERY IDs +#define RAINMETER_QUERY_ID_SKINS_PATH 4101 +#define RAINMETER_QUERY_ID_SETTINGS_PATH 4102 +#define RAINMETER_QUERY_ID_PLUGINS_PATH 4103 + +#endif diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 517f99f9..acd24c67 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -23,6 +23,7 @@ #include "Rainmeter.h" #include "AboutDialog.h" #include "Error.h" +#include "RainmeterQuery.h" #include #include @@ -620,7 +621,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA break; case WM_QUERY_RAINMETER: - if (Rainmeter && IsWindow((HWND)lParam)) { if(wParam == RAINMETER_QUERY_ID_SKINS_PATH) @@ -630,7 +630,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA COPYDATASTRUCT cds; cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH; - cds.cbData = (path.size() + 1) * 2; + cds.cbData = (path.size() + 1) * sizeof(wchar_t); cds.lpData = (LPVOID) path.c_str(); SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); @@ -644,7 +644,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA COPYDATASTRUCT cds; cds.dwData = RAINMETER_QUERY_ID_SETTINGS_PATH; - cds.cbData = (path.size() + 1) * 2; + cds.cbData = (path.size() + 1) * sizeof(wchar_t); cds.lpData = (LPVOID) path.c_str(); SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); @@ -658,7 +658,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA COPYDATASTRUCT cds; cds.dwData = RAINMETER_QUERY_ID_PLUGINS_PATH; - cds.cbData = (path.size() + 1) * 2; + cds.cbData = (path.size() + 1) * sizeof(wchar_t); cds.lpData = (LPVOID) path.c_str(); SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds); diff --git a/Library/resource.h b/Library/resource.h index 14beb021..66099c1d 100644 --- a/Library/resource.h +++ b/Library/resource.h @@ -60,13 +60,6 @@ #define ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT 4049 #define ID_CONTEXT_NEW_VERSION 4050 -#define WM_QUERY_RAINMETER WM_APP + 1000 - -#define RAINMETER_QUERY_ID_SKINS_PATH 4101 -#define RAINMETER_QUERY_ID_SETTINGS_PATH 4102 -#define RAINMETER_QUERY_ID_PLUGINS_PATH 4103 - - #define ID_CONFIG_EDIT 30000 #define ID_CONFIG_FIRST 30001 #define ID_CONFIG_LAST 33000