Added changes by JamesAC, Spx and Patrick/Dexpot to expand the range of information which can be requested from Rainmeter via Windows Messages. (SendMessage/WM_COPYDATA)

See the header file RainmeterQuery.h for details and usage help.
This commit is contained in:
jsmorley 2010-06-28 22:30:20 +00:00
parent 92f67ec7db
commit b16f02d243
4 changed files with 250 additions and 7 deletions

View File

@ -28,8 +28,8 @@ LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,448 FILEVERSION 1,3,0,451
PRODUCTVERSION 1,3,0,448 PRODUCTVERSION 1,3,0,451
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -45,12 +45,12 @@ BEGIN
BLOCK "040b04b0" BLOCK "040b04b0"
BEGIN BEGIN
VALUE "FileDescription", "Rainmeter - A Customizable Resource Meter" VALUE "FileDescription", "Rainmeter - A Customizable Resource Meter"
VALUE "FileVersion", "1, 3, 0, 442" VALUE "FileVersion", "1, 3, 0, 451"
VALUE "InternalName", "Rainmeter" VALUE "InternalName", "Rainmeter"
VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy" VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy"
VALUE "OriginalFilename", "Rainmeter.exe" VALUE "OriginalFilename", "Rainmeter.exe"
VALUE "ProductName", "Rainmeter" VALUE "ProductName", "Rainmeter"
VALUE "ProductVersion", "1, 3, 0, 442" VALUE "ProductVersion", "1, 3, 0, 451"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -19,6 +19,7 @@
/* /*
Rainmeter query interface based on Window Message Rainmeter query interface based on Window Message
The majority of the queries work as detailed below, other queries are explained along with their definitions.
Usage: Usage:
1) Post the query to Rainmeter (E.g. QueryRainmeterSkinsPath function) 1) Post the query to Rainmeter (E.g. QueryRainmeterSkinsPath function)
* target window : Rainmeter(TrayWindow) * target window : Rainmeter(TrayWindow)
@ -28,7 +29,7 @@ Usage:
2) Retrieve the data received from Rainmeter, on WM_COPYDATA 2) Retrieve the data received from Rainmeter, on WM_COPYDATA
* COPYDATASTRUCT->dwData : QUERY ID (RAINMETER_QUERY_ID_XXXXX) * COPYDATASTRUCT->dwData : QUERY ID (RAINMETER_QUERY_ID_XXXXX)
* COPYDATASTRUCT->lpData : requested string in wide char * COPYDATASTRUCT->lpData : requested information. Form depends on you request.
* COPYDATASTRUCT->cbData : size of lpData * COPYDATASTRUCT->cbData : size of lpData
----- -----
@ -79,10 +80,56 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
#define RAINMETER_QUERY_WINDOW_NAME NULL #define RAINMETER_QUERY_WINDOW_NAME NULL
#define WM_QUERY_RAINMETER WM_APP + 1000 #define WM_QUERY_RAINMETER WM_APP + 1000
#define WM_QUERY_RAINMETER_RETURN WM_APP + 1001
// QUERY IDs /*
QUERY IDs
These Queries return a string in a wide char format
*/
#define RAINMETER_QUERY_ID_SKINS_PATH 4101 #define RAINMETER_QUERY_ID_SKINS_PATH 4101
#define RAINMETER_QUERY_ID_SETTINGS_PATH 4102 #define RAINMETER_QUERY_ID_SETTINGS_PATH 4102
#define RAINMETER_QUERY_ID_PLUGINS_PATH 4103 #define RAINMETER_QUERY_ID_PLUGINS_PATH 4103
#define RAINMETER_QUERY_ID_PROGRAM_PATH 4104
#define RAINMETER_QUERY_ID_LOG_PATH 4105
#define RAINMETER_QUERY_ID_CONFIG_EDITOR 4106
#define RAINMETER_QUERY_ID_COMMAND_LINE 4107
#define RAINMETER_QUERY_ID_STATS_DATE 4108
#define RAINMETER_QUERY_ID_TRAY_EX_L 4109
#define RAINMETER_QUERY_ID_TRAY_EX_R 4110
#define RAINMETER_QUERY_ID_TRAY_EX_M 4111
#define RAINMETER_QUERY_ID_TRAY_EX_DL 4112
#define RAINMETER_QUERY_ID_TRAY_EX_DR 4113
#define RAINMETER_QUERY_ID_TRAY_EX_DM 4114
/*
These Queries return a numerical value in a direct message, the data
is stored in the lParam of the message sent to your window, and the msg section
will contain WM_QUERY_RAINMETER_RETURN
*/
#define RAINMETER_QUERY_ID_VERSION_CHECK 4115 //0 for disabled, 1 for checking, 2 for new version available
#define RAINMETER_QUERY_ID_IS_DEBUGGING 4116
#define RAINMETER_QUERY_ID_IS_LITESTEP 4117
/*QUERY IDs used with WM_COPYDATA
Usage: Send a WM_COPYDATA message to rainmeter via SendMessage().
Rainmeter will set the return value depending on the contents
of the COPYDATASTRUCT.
*/
#define RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE 5101
/*
This Retuns the Window Handle of the active skin requested by config name in cds.lpData,
or NULL if the config is not loaded. Currently, the config name is Case-Sensitive.
To requst the data, send a message to Rainmeter in a way similar to this example.
COPYDATASTRUCT cds;
LPWSTR SkinName = L"Gnometer\\Clock";
cds.dwData = 5101;
cds.lpData = SkinName;
cds.cbData = (wcslen(SkinName) + 1) * 2;
HWND hWndMeter = (HWND) SendMessage(hWndRainmeter, WM_COPYDATA, (WPARAM) hWndYourWindow, (LPARAM) &cds);
*/
#endif #endif

View File

@ -665,6 +665,202 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 0; return 0;
} }
else if(wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
{
std::wstring path = Rainmeter->GetPath();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_PROGRAM_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) path.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_LOG_PATH)
{
std::wstring path = Rainmeter->GetLogFile();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_LOG_PATH;
cds.cbData = (path.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) path.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
{
std::wstring editor = Rainmeter->GetConfigEditor();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_CONFIG_EDITOR;
cds.cbData = (editor.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) editor.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_COMMAND_LINE)
{
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();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
{
UINT versioncheck = (Rainmeter->GetDisableVersionCheck() * (Rainmeter->GetDisableVersionCheck() + Rainmeter->GetNewVersion()));
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) versioncheck);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
{
BOOL debug = Rainmeter->GetDebug();
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) debug);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_STATS_DATE)
{
std::wstring date = Rainmeter->GetStatsDate();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_STATS_DATE;
cds.cbData = (date.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) date.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
{
std::wstring tray = Rainmeter->GetTrayExecuteL();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_L;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
{
std::wstring tray = Rainmeter->GetTrayExecuteR();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_R;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
{
std::wstring tray = Rainmeter->GetTrayExecuteM();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_M;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
{
std::wstring tray = Rainmeter->GetTrayExecuteDL();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DL;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
{
std::wstring tray = Rainmeter->GetTrayExecuteDR();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DR;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
{
std::wstring tray = Rainmeter->GetTrayExecuteDM();
COPYDATASTRUCT cds;
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DM;
cds.cbData = (tray.size() + 1) * sizeof(wchar_t);
cds.lpData = (LPVOID) tray.c_str();
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
return 0;
}
else if(wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
{
BOOL islitestep = !Rainmeter->GetDummyLitestep();
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM) islitestep);
return 0;
}
}
return 1;
case WM_COPYDATA:
if(Rainmeter)
{
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
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())
{
return (LRESULT) iter->second->GetWindow();
}
return NULL;
}
} }
return 1; return 1;

View File

@ -1,2 +1,2 @@
#pragma once #pragma once
const int revision_number = 448; const int revision_number = 451;