mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Added RainmeterQuery.h for querying the data from the other applications by using Window Message. Thus modified some related codes.
This commit is contained in:
		@@ -2873,16 +2873,20 @@
 | 
				
			|||||||
				RelativePath="Rainmeter.h"
 | 
									RelativePath="Rainmeter.h"
 | 
				
			||||||
				>
 | 
									>
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
 | 
								<File
 | 
				
			||||||
 | 
									RelativePath="RainmeterQuery.h"
 | 
				
			||||||
 | 
									>
 | 
				
			||||||
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="resource.h"
 | 
									RelativePath="resource.h"
 | 
				
			||||||
				>
 | 
									>
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath=".\StdAfx.h"
 | 
									RelativePath="StdAfx.h"
 | 
				
			||||||
				>
 | 
									>
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath=".\System.h"
 | 
									RelativePath="System.h"
 | 
				
			||||||
				>
 | 
									>
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										88
									
								
								Library/RainmeterQuery.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								Library/RainmeterQuery.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,88 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					  Copyright (C) 2010 JamesAC, spx
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  This program is free software; you can redistribute it and/or
 | 
				
			||||||
 | 
					  modify it under the terms of the GNU General Public License
 | 
				
			||||||
 | 
					  as published by the Free Software Foundation; either version 2
 | 
				
			||||||
 | 
					  of the License, or (at your option) any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					  but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					  GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					  along with this program; if not, write to the Free Software
 | 
				
			||||||
 | 
					  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					Rainmeter query interface based on Window Message
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Usage:
 | 
				
			||||||
 | 
					1) Post the query to Rainmeter (E.g. QueryRainmeterSkinsPath function)
 | 
				
			||||||
 | 
					   * target window : Rainmeter(TrayWindow)
 | 
				
			||||||
 | 
					   * message       : WM_QUERY_RAINMETER
 | 
				
			||||||
 | 
					   * wParam        : QUERY ID (RAINMETER_QUERY_ID_XXXXX)
 | 
				
			||||||
 | 
					   * lParam        : window handle which receives WM_COPYDATA
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					2) Retrieve the data received from Rainmeter, on WM_COPYDATA
 | 
				
			||||||
 | 
					   * COPYDATASTRUCT->dwData : QUERY ID (RAINMETER_QUERY_ID_XXXXX)
 | 
				
			||||||
 | 
					   * COPYDATASTRUCT->lpData : requested string in wide char
 | 
				
			||||||
 | 
					   * COPYDATASTRUCT->cbData : size of lpData
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-----
 | 
				
			||||||
 | 
					#include <Windows.h>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					#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 <tchar.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#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
 | 
				
			||||||
@@ -23,6 +23,7 @@
 | 
				
			|||||||
#include "Rainmeter.h"
 | 
					#include "Rainmeter.h"
 | 
				
			||||||
#include "AboutDialog.h"
 | 
					#include "AboutDialog.h"
 | 
				
			||||||
#include "Error.h"
 | 
					#include "Error.h"
 | 
				
			||||||
 | 
					#include "RainmeterQuery.h"
 | 
				
			||||||
#include <io.h>
 | 
					#include <io.h>
 | 
				
			||||||
#include <ShellAPI.h>
 | 
					#include <ShellAPI.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -620,7 +621,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 | 
				
			|||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	case WM_QUERY_RAINMETER:
 | 
						case WM_QUERY_RAINMETER:
 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (Rainmeter && IsWindow((HWND)lParam))
 | 
							if (Rainmeter && IsWindow((HWND)lParam))
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
 | 
								if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
 | 
				
			||||||
@@ -630,7 +630,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
 | 
				
			|||||||
				COPYDATASTRUCT cds;
 | 
									COPYDATASTRUCT cds;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
				cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
 | 
									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();
 | 
									cds.lpData = (LPVOID) path.c_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
 | 
									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;
 | 
									COPYDATASTRUCT cds;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
				cds.dwData = RAINMETER_QUERY_ID_SETTINGS_PATH;
 | 
									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();
 | 
									cds.lpData = (LPVOID) path.c_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
 | 
									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;
 | 
									COPYDATASTRUCT cds;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
				cds.dwData = RAINMETER_QUERY_ID_PLUGINS_PATH;
 | 
									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();
 | 
									cds.lpData = (LPVOID) path.c_str();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
 | 
									SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,13 +60,6 @@
 | 
				
			|||||||
#define ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT	4049
 | 
					#define ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT	4049
 | 
				
			||||||
#define ID_CONTEXT_NEW_VERSION				4050
 | 
					#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_EDIT                  30000
 | 
				
			||||||
#define ID_CONFIG_FIRST                 30001
 | 
					#define ID_CONFIG_FIRST                 30001
 | 
				
			||||||
#define ID_CONFIG_LAST					33000
 | 
					#define ID_CONFIG_LAST					33000
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user