2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Kimmo Pekkola
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "TrayWindow.h"
|
2011-02-07 08:02:12 +00:00
|
|
|
#include "Measure.h"
|
|
|
|
#include "resource.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Litestep.h"
|
|
|
|
#include "Rainmeter.h"
|
2011-08-28 10:58:26 +00:00
|
|
|
#include "DialogAbout.h"
|
|
|
|
#include "DialogManage.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Error.h"
|
2010-06-21 19:48:00 +00:00
|
|
|
#include "RainmeterQuery.h"
|
2011-02-03 15:52:45 +00:00
|
|
|
#include "../Version.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
#define TRAYTIMER 3
|
|
|
|
|
2011-09-17 19:30:31 +00:00
|
|
|
#define RAINMETER_OFFICIAL L"http://rainmeter.net/cms/"
|
|
|
|
#define RAINMETER_MANUAL L"http://rainmeter.net/cms/Manual"
|
|
|
|
#define RAINMETER_MANUALBETA L"http://rainmeter.net/cms/Manual_beta"
|
2010-08-05 17:48:52 +00:00
|
|
|
|
2011-09-03 21:51:25 +00:00
|
|
|
#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)
|
|
|
|
|
2011-04-19 00:02:00 +00:00
|
|
|
const UINT WM_TASKBARCREATED = ::RegisterWindowMessage(L"TaskbarCreated");
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
extern CRainmeter* Rainmeter;
|
|
|
|
|
|
|
|
using namespace Gdiplus;
|
|
|
|
|
2010-11-11 20:24:59 +00:00
|
|
|
CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_TrayIcon(),
|
|
|
|
m_Measure(),
|
|
|
|
m_MeterType(TRAY_METER_TYPE_HISTOGRAM),
|
2010-11-11 20:24:59 +00:00
|
|
|
m_TrayColor1(0, 100, 0),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_TrayColor2(0, 255, 0),
|
|
|
|
m_Bitmap(),
|
|
|
|
m_TrayValues(),
|
2011-04-19 00:02:00 +00:00
|
|
|
m_TrayPos(),
|
|
|
|
m_TrayIconEnabled(true)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-10-01 06:27:20 +00:00
|
|
|
WNDCLASS wc = {0};
|
2009-02-10 18:37:48 +00:00
|
|
|
wc.lpfnWndProc = (WNDPROC)WndProc;
|
|
|
|
wc.hInstance = instance;
|
|
|
|
wc.lpszClassName = L"RainmeterTrayClass";
|
|
|
|
|
|
|
|
RegisterClass(&wc);
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
m_Window = CreateWindowEx(
|
|
|
|
WS_EX_TOOLWINDOW,
|
|
|
|
L"RainmeterTrayClass",
|
|
|
|
NULL,
|
2011-09-03 21:51:25 +00:00
|
|
|
WS_POPUP | WS_DISABLED,
|
2009-02-10 18:37:48 +00:00
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
instance,
|
|
|
|
this);
|
|
|
|
|
2011-09-03 21:51:25 +00:00
|
|
|
SetWindowPos(m_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CTrayWindow::~CTrayWindow()
|
|
|
|
{
|
|
|
|
KillTimer(m_Window, TRAYTIMER);
|
|
|
|
RemoveTrayIcon();
|
|
|
|
|
2010-12-08 02:46:41 +00:00
|
|
|
delete m_Bitmap;
|
|
|
|
delete m_Measure;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
DestroyIcon(m_TrayIcons[i]);
|
|
|
|
}
|
|
|
|
m_TrayIcons.clear();
|
|
|
|
|
|
|
|
if (m_Window) DestroyWindow(m_Window);
|
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
BOOL CTrayWindow::AddTrayIcon()
|
|
|
|
{
|
|
|
|
BOOL res = FALSE;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_TrayIcon)
|
|
|
|
{
|
|
|
|
DestroyIcon(m_TrayIcon);
|
|
|
|
m_TrayIcon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_TrayIcon = CreateTrayIcon(0);
|
|
|
|
|
|
|
|
if (m_TrayIcon)
|
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
2011-03-29 19:21:57 +00:00
|
|
|
tnid.hWnd = m_Window;
|
2009-02-10 18:37:48 +00:00
|
|
|
tnid.uID = IDI_TRAY;
|
2011-03-29 19:21:57 +00:00
|
|
|
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
|
|
|
tnid.uCallbackMessage = WM_TRAY_NOTIFYICON;
|
2009-02-10 18:37:48 +00:00
|
|
|
tnid.hIcon = m_TrayIcon;
|
2011-03-29 19:21:57 +00:00
|
|
|
wcsncpy_s(tnid.szTip, L"Rainmeter", _TRUNCATE);
|
|
|
|
|
|
|
|
res = Shell_NotifyIcon(NIM_ADD, &tnid);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
return res;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
BOOL CTrayWindow::RemoveTrayIcon()
|
|
|
|
{
|
|
|
|
BOOL res = FALSE;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
if (m_TrayIcon)
|
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
2011-03-29 19:21:57 +00:00
|
|
|
tnid.hWnd = m_Window;
|
|
|
|
tnid.uID = IDI_TRAY;
|
|
|
|
tnid.uFlags = 0;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
res = Shell_NotifyIcon(NIM_DELETE, &tnid);
|
|
|
|
|
|
|
|
DestroyIcon(m_TrayIcon);
|
|
|
|
m_TrayIcon = NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
return res;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
BOOL CTrayWindow::ModifyTrayIcon(double value)
|
|
|
|
{
|
|
|
|
BOOL res = FALSE;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
if (m_TrayIcon)
|
|
|
|
{
|
|
|
|
DestroyIcon(m_TrayIcon);
|
|
|
|
m_TrayIcon = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_TrayIcon = CreateTrayIcon(value);
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2010-11-25 22:00:34 +00:00
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
2011-03-29 19:21:57 +00:00
|
|
|
tnid.hWnd = m_Window;
|
2009-02-10 18:37:48 +00:00
|
|
|
tnid.uID = IDI_TRAY;
|
2011-03-29 19:21:57 +00:00
|
|
|
tnid.uFlags = NIF_ICON;
|
2009-02-10 18:37:48 +00:00
|
|
|
tnid.hIcon = m_TrayIcon;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
|
|
|
return res;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
HICON CTrayWindow::CreateTrayIcon(double value)
|
|
|
|
{
|
2009-10-30 19:10:55 +00:00
|
|
|
if (m_Measure != NULL)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
m_TrayValues[m_TrayPos] = value;
|
|
|
|
m_TrayPos = (m_TrayPos + 1) % TRAYICON_SIZE;
|
|
|
|
|
|
|
|
Bitmap trayBitmap(TRAYICON_SIZE, TRAYICON_SIZE);
|
|
|
|
Graphics graphics(&trayBitmap);
|
|
|
|
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
|
|
|
|
|
|
|
Point points[TRAYICON_SIZE + 2];
|
|
|
|
points[0].X = 0;
|
|
|
|
points[0].Y = TRAYICON_SIZE;
|
|
|
|
points[TRAYICON_SIZE + 1].X = TRAYICON_SIZE - 1;
|
|
|
|
points[TRAYICON_SIZE + 1].Y = TRAYICON_SIZE;
|
|
|
|
|
2010-03-30 22:37:05 +00:00
|
|
|
for (int i = 0; i < TRAYICON_SIZE; ++i)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
points[i + 1].X = i;
|
|
|
|
points[i + 1].Y = (int)(TRAYICON_SIZE * (1.0 - m_TrayValues[(m_TrayPos + i) % TRAYICON_SIZE]));
|
|
|
|
}
|
|
|
|
|
|
|
|
SolidBrush brush(m_TrayColor1);
|
|
|
|
graphics.FillRectangle(&brush, 0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
|
|
|
|
|
|
|
SolidBrush brush2(m_TrayColor2);
|
|
|
|
graphics.FillPolygon(&brush2, points, TRAYICON_SIZE + 2);
|
|
|
|
|
|
|
|
HICON icon;
|
|
|
|
trayBitmap.GetHICON(&icon);
|
|
|
|
return icon;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_TrayIcons.size() > 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
size_t frame = 0;
|
|
|
|
size_t frameCount = m_TrayIcons.size();
|
|
|
|
|
|
|
|
// Select the correct frame linearly
|
|
|
|
frame = (size_t)(value * frameCount);
|
|
|
|
frame = min((frameCount - 1), frame);
|
|
|
|
|
|
|
|
return CopyIcon(m_TrayIcons[frame]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int frame = 0;
|
|
|
|
int frameCount = 0;
|
|
|
|
int newX, newY;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
frameCount = m_Bitmap->GetWidth() / TRAYICON_SIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frameCount = m_Bitmap->GetHeight() / TRAYICON_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select the correct frame linearly
|
|
|
|
frame = (int)(value * frameCount);
|
|
|
|
frame = min((frameCount - 1), frame);
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
newX = frame * TRAYICON_SIZE;
|
|
|
|
newY = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newX = 0;
|
|
|
|
newY = frame * TRAYICON_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bitmap trayBitmap(TRAYICON_SIZE, TRAYICON_SIZE);
|
|
|
|
Graphics graphics(&trayBitmap);
|
|
|
|
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
|
|
|
|
|
|
|
// Blit the image
|
|
|
|
Rect r(0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
|
|
|
graphics.DrawImage(m_Bitmap, r, newX, newY, TRAYICON_SIZE, TRAYICON_SIZE, UnitPixel);
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
HICON icon;
|
|
|
|
trayBitmap.GetHICON(&icon);
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-30 19:10:55 +00:00
|
|
|
// Return the default icon if there is no valid measure
|
|
|
|
return LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CTrayWindow::ReadConfig(CConfigParser& parser)
|
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
// Clear old Settings
|
2010-12-21 04:49:01 +00:00
|
|
|
KillTimer(m_Window, TRAYTIMER);
|
|
|
|
|
2010-12-06 08:59:55 +00:00
|
|
|
delete m_Measure;
|
|
|
|
m_Measure = NULL;
|
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
delete m_Bitmap;
|
|
|
|
m_Bitmap = NULL;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
DestroyIcon(m_TrayIcons[i]);
|
|
|
|
}
|
|
|
|
m_TrayIcons.clear();
|
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
m_MeterType = TRAY_METER_TYPE_NONE;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
// Read tray settings
|
|
|
|
m_TrayIconEnabled = 0!=parser.ReadInt(L"Rainmeter", L"TrayIcon", 1);
|
|
|
|
if (m_TrayIconEnabled)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
std::wstring measureName = parser.ReadString(L"TrayMeasure", L"Measure", L"");
|
2010-12-06 08:59:55 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
if (!measureName.empty())
|
2010-12-06 08:59:55 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
CConfigParser* oldParser = Rainmeter->GetCurrentParser();
|
|
|
|
Rainmeter->SetCurrentParser(&parser);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure");
|
|
|
|
if (m_Measure)
|
|
|
|
{
|
|
|
|
m_Measure->ReadConfig(parser);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (CError& error)
|
2010-12-06 08:59:55 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
delete m_Measure;
|
|
|
|
m_Measure = NULL;
|
2011-09-08 17:05:48 +00:00
|
|
|
LogError(error);
|
2010-12-06 08:59:55 +00:00
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
|
|
|
|
Rainmeter->SetCurrentParser(oldParser);
|
2010-12-06 08:59:55 +00:00
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
|
|
|
|
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE");
|
|
|
|
if (_wcsicmp(type.c_str(), L"NONE") == 0)
|
2010-12-06 08:59:55 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
// Use main icon
|
2010-12-06 08:59:55 +00:00
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
else if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
|
|
|
{
|
|
|
|
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
|
|
|
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
|
|
|
|
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
|
|
|
|
{
|
|
|
|
m_MeterType = TRAY_METER_TYPE_BITMAP;
|
2010-12-06 08:59:55 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
std::wstring imageName = parser.ReadString(L"TrayMeasure", L"TrayBitmap", L"");
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
// Load the bitmaps if defined
|
|
|
|
if (!imageName.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
imageName.insert(0, Rainmeter->GetSkinPath());
|
|
|
|
if (imageName.size() > 3)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
std::wstring extension = imageName.substr(imageName.size() - 3);
|
|
|
|
if (extension == L"ico" || extension == L"ICO")
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
int count = 1;
|
|
|
|
HICON hIcon = NULL;
|
|
|
|
|
|
|
|
// Load the icons
|
|
|
|
do
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
_snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++);
|
|
|
|
|
|
|
|
hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
|
|
|
|
if (hIcon) m_TrayIcons.push_back(hIcon);
|
|
|
|
if (imageName == buffer) break;
|
|
|
|
} while(hIcon != NULL);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
if (m_TrayIcons.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
// No icons found so load as bitmap
|
2009-02-10 18:37:48 +00:00
|
|
|
delete m_Bitmap;
|
2011-07-15 16:54:47 +00:00
|
|
|
m_Bitmap = new Bitmap(imageName.c_str());
|
|
|
|
Status status = m_Bitmap->GetLastStatus();
|
|
|
|
if (Ok != status)
|
|
|
|
{
|
|
|
|
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
|
|
|
|
delete m_Bitmap;
|
|
|
|
m_Bitmap = NULL;
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
LogWithArgs(LOG_ERROR, L"No such TrayMeter: %s", type.c_str());
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
AddTrayIcon();
|
2010-12-21 04:49:01 +00:00
|
|
|
|
|
|
|
if (m_Measure)
|
|
|
|
{
|
|
|
|
SetTimer(m_Window, TRAYTIMER, 1000, NULL); // Update the tray once per sec
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-04-19 00:02:00 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
RemoveTrayIcon();
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static CTrayWindow* tray = NULL;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (uMsg == WM_CREATE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
|
|
|
}
|
2011-04-19 00:02:00 +00:00
|
|
|
else if (uMsg == WM_TASKBARCREATED)
|
|
|
|
{
|
|
|
|
if (tray && tray->IsTrayIconEnabled())
|
|
|
|
{
|
|
|
|
tray->RemoveTrayIcon();
|
|
|
|
tray->AddTrayIcon();
|
|
|
|
}
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
switch (uMsg)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
case WM_COMMAND:
|
|
|
|
if (Rainmeter && tray)
|
|
|
|
{
|
2011-08-28 10:58:26 +00:00
|
|
|
if (wParam == ID_CONTEXT_MANAGE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-08-28 10:58:26 +00:00
|
|
|
CDialogManage::Open();
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
else if (wParam == ID_CONTEXT_ABOUT)
|
2010-10-25 19:58:53 +00:00
|
|
|
{
|
2011-08-28 10:58:26 +00:00
|
|
|
CDialogAbout::Open();
|
2010-10-25 19:58:53 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_SHOW_HELP)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-09-28 18:28:35 +00:00
|
|
|
RunCommand(NULL, revision_beta ? RAINMETER_MANUALBETA : RAINMETER_MANUAL, SW_SHOWNORMAL);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_NEW_VERSION)
|
2010-07-07 23:46:44 +00:00
|
|
|
{
|
2011-09-28 18:28:35 +00:00
|
|
|
RunCommand(NULL, RAINMETER_OFFICIAL, SW_SHOWNORMAL);
|
2010-07-07 23:46:44 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_REFRESH)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-02-16 14:46:17 +00:00
|
|
|
PostMessage(tray->GetWindow(), WM_TRAY_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
|
|
|
else if (wParam == ID_CONTEXT_SHOWLOGFILE)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
// Check if the file exists
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& log = Rainmeter->GetLogFile();
|
2009-02-10 18:37:48 +00:00
|
|
|
if (_waccess(log.c_str(), 0) != -1)
|
|
|
|
{
|
2011-09-08 14:39:25 +00:00
|
|
|
std::wstring command = Rainmeter->GetLogViewer() + log;
|
2011-09-28 18:28:35 +00:00
|
|
|
RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2010-07-07 23:46:44 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_STARTLOG)
|
2010-07-07 23:46:44 +00:00
|
|
|
{
|
2010-07-08 10:59:06 +00:00
|
|
|
Rainmeter->StartLogging();
|
2010-07-07 23:46:44 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_STOPLOG)
|
2010-07-07 23:46:44 +00:00
|
|
|
{
|
2010-07-08 10:59:06 +00:00
|
|
|
Rainmeter->StopLogging();
|
2010-07-07 23:46:44 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_DELETELOGFILE)
|
2010-07-07 23:46:44 +00:00
|
|
|
{
|
2010-07-08 10:59:06 +00:00
|
|
|
Rainmeter->DeleteLogFile();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_DEBUGLOG)
|
2010-07-07 23:46:44 +00:00
|
|
|
{
|
2011-09-28 18:28:35 +00:00
|
|
|
Rainmeter->SetDebug(!Rainmeter->GetDebug());
|
2010-07-07 23:46:44 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_DISABLEDRAG)
|
2010-11-24 15:34:07 +00:00
|
|
|
{
|
2010-11-27 10:57:59 +00:00
|
|
|
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
|
2010-11-24 15:34:07 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_EDITCONFIG)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
std::wstring command = Rainmeter->GetConfigEditor() + L" \"";
|
2009-02-10 18:37:48 +00:00
|
|
|
command += Rainmeter->GetIniFile();
|
2009-08-12 17:11:52 +00:00
|
|
|
command += L"\"";
|
2011-09-28 18:28:35 +00:00
|
|
|
RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
2009-08-12 17:11:52 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_QUIT)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-09-28 18:28:35 +00:00
|
|
|
PostQuitMessage(0);
|
2011-09-29 06:04:20 +00:00
|
|
|
Quit();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == ID_CONTEXT_OPENSKINSFOLDER)
|
2009-07-24 07:56:37 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
std::wstring command = L"\"" + Rainmeter->GetSkinPath();
|
2009-07-24 07:56:37 +00:00
|
|
|
command += L"\"";
|
2011-09-28 18:28:35 +00:00
|
|
|
RunCommand(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
2009-07-24 07:56:37 +00:00
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if ((wParam & 0x0ffff) >= ID_THEME_FIRST && (wParam & 0x0ffff) <= ID_THEME_LAST)
|
2009-08-12 17:11:52 +00:00
|
|
|
{
|
|
|
|
int pos = (wParam & 0x0ffff) - ID_THEME_FIRST;
|
|
|
|
|
|
|
|
const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes();
|
2009-09-18 15:30:51 +00:00
|
|
|
if (pos >= 0 && pos < (int)themes.size())
|
2009-08-12 17:11:52 +00:00
|
|
|
{
|
2011-09-04 07:40:12 +00:00
|
|
|
Rainmeter->LoadTheme(themes[pos]);
|
2009-08-12 17:11:52 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if ((wParam & 0x0ffff) >= ID_CONFIG_FIRST && (wParam & 0x0ffff) <= ID_CONFIG_LAST)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-10-29 10:36:07 +00:00
|
|
|
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex((UINT)(wParam & 0x0ffff));
|
|
|
|
if (indexes.first != -1 && indexes.second != -1)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-10-29 10:36:07 +00:00
|
|
|
Rainmeter->ToggleConfig(indexes.first, indexes.second);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Forward the message to correct window
|
|
|
|
int index = (int)(wParam >> 16);
|
2011-01-24 10:15:05 +00:00
|
|
|
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2009-02-14 10:11:28 +00:00
|
|
|
if (index < (int)windows.size())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
2011-03-29 19:21:57 +00:00
|
|
|
for ( ; iter != windows.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-03-30 22:37:05 +00:00
|
|
|
--index;
|
2009-02-10 18:37:48 +00:00
|
|
|
if (index < 0)
|
|
|
|
{
|
|
|
|
CMeterWindow* meterWindow = (*iter).second;
|
|
|
|
SendMessage(meterWindow->GetWindow(), WM_COMMAND, wParam & 0x0FFFF, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0; // Don't send WM_COMMANDS any further
|
|
|
|
|
2011-02-16 14:46:17 +00:00
|
|
|
case WM_TRAY_NOTIFYICON:
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-03-29 19:21:57 +00:00
|
|
|
UINT uMouseMsg = (UINT)lParam;
|
2009-02-10 18:37:48 +00:00
|
|
|
std::wstring bang;
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
switch (uMouseMsg)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
bang = Rainmeter->GetTrayExecuteL();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
bang = Rainmeter->GetTrayExecuteM();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
bang = Rainmeter->GetTrayExecuteR();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
bang = Rainmeter->GetTrayExecuteDL();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDBLCLK:
|
|
|
|
bang = Rainmeter->GetTrayExecuteDM();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
|
|
|
bang = Rainmeter->GetTrayExecuteDR();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-08 04:35:04 +00:00
|
|
|
if (!(GetKeyState(VK_CONTROL) < 0) && // Ctrl is pressed, so only run default action
|
2011-09-03 14:29:17 +00:00
|
|
|
!bang.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-09-02 16:03:15 +00:00
|
|
|
Rainmeter->ExecuteCommand(bang.c_str(), NULL);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2011-08-28 10:58:26 +00:00
|
|
|
else if (uMouseMsg == WM_RBUTTONDOWN)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
POINT point;
|
|
|
|
GetCursorPos(&point);
|
|
|
|
Rainmeter->ShowContextMenu(point, NULL);
|
|
|
|
}
|
2011-10-14 14:53:02 +00:00
|
|
|
else if (uMouseMsg == WM_LBUTTONDOWN || uMouseMsg == WM_LBUTTONDBLCLK)
|
2011-08-28 10:58:26 +00:00
|
|
|
{
|
|
|
|
CDialogManage::Open();
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-20 20:52:52 +00:00
|
|
|
case WM_QUERY_RAINMETER:
|
|
|
|
if (Rainmeter && IsWindow((HWND)lParam))
|
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
COPYDATASTRUCT cds;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
if (wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
2010-06-20 20:52:52 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& path = Rainmeter->GetSkinPath();
|
2010-06-20 20:52:52 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((path.size() + 1) * sizeof(wchar_t));
|
2010-06-20 20:52:52 +00:00
|
|
|
cds.lpData = (LPVOID) path.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2010-06-20 20:52:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
2010-06-20 20:52:52 +00:00
|
|
|
{
|
|
|
|
std::wstring path = Rainmeter->GetSettingsPath();
|
|
|
|
|
2010-06-21 16:00:19 +00:00
|
|
|
cds.dwData = RAINMETER_QUERY_ID_SETTINGS_PATH;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((path.size() + 1) * sizeof(wchar_t));
|
2010-06-20 20:52:52 +00:00
|
|
|
cds.lpData = (LPVOID) path.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
2010-06-20 20:52:52 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& path = Rainmeter->GetPluginPath();
|
2010-06-20 20:52:52 +00:00
|
|
|
|
2010-06-21 16:00:19 +00:00
|
|
|
cds.dwData = RAINMETER_QUERY_ID_PLUGINS_PATH;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((path.size() + 1) * sizeof(wchar_t));
|
2010-06-20 20:52:52 +00:00
|
|
|
cds.lpData = (LPVOID) path.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& path = Rainmeter->GetPath();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_PROGRAM_PATH;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((path.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) path.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& path = Rainmeter->GetLogFile();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_LOG_PATH;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((path.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) path.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& editor = Rainmeter->GetConfigEditor();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_CONFIG_EDITOR;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((editor.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) editor.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_VERSION_CHECK)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2011-08-28 10:58:26 +00:00
|
|
|
UINT versioncheck = ((int)Rainmeter->GetDisableVersionCheck() * ((int)Rainmeter->GetDisableVersionCheck() + (int)Rainmeter->GetNewVersion()));
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)versioncheck);
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
|
|
|
BOOL debug = Rainmeter->GetDebug();
|
|
|
|
|
2011-08-28 10:58:26 +00:00
|
|
|
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_STATS_DATE)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& date = Rainmeter->GetStatsDate();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_STATS_DATE;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((date.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) date.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_L)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteL();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_L;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_R)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteR();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_R;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_M)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteM();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_M;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DL)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteDL();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DL;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DR)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteDR();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DR;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_TRAY_EX_DM)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2010-11-25 22:00:34 +00:00
|
|
|
const std::wstring& tray = Rainmeter->GetTrayExecuteDM();
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
cds.dwData = RAINMETER_QUERY_ID_TRAY_EX_DM;
|
2010-12-16 20:35:44 +00:00
|
|
|
cds.cbData = (DWORD)((tray.size() + 1) * sizeof(wchar_t));
|
2010-06-28 22:30:20 +00:00
|
|
|
cds.lpData = (LPVOID) tray.c_str();
|
|
|
|
|
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
else if (wParam == RAINMETER_QUERY_ID_IS_LITESTEP)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
2011-09-28 18:28:35 +00:00
|
|
|
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)0);
|
2010-06-28 22:30:20 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case WM_COPYDATA:
|
2011-03-29 19:21:57 +00:00
|
|
|
if (Rainmeter)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
|
|
|
COPYDATASTRUCT *cds = (COPYDATASTRUCT*) lParam;
|
2011-03-29 19:21:57 +00:00
|
|
|
if (cds->dwData == RAINMETER_QUERY_ID_SKIN_WINDOWHANDLE)
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
|
|
|
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);
|
2011-03-29 19:21:57 +00:00
|
|
|
if (iter != MeterWindows.end())
|
2010-06-28 22:30:20 +00:00
|
|
|
{
|
|
|
|
return (LRESULT) iter->second->GetWindow();
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
return NULL;
|
2010-06-28 22:30:20 +00:00
|
|
|
}
|
2010-06-20 20:52:52 +00:00
|
|
|
}
|
|
|
|
return 1;
|
2010-06-21 16:00:19 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
case WM_TIMER:
|
|
|
|
if (tray && tray->m_Measure)
|
|
|
|
{
|
|
|
|
tray->m_Measure->Update();
|
|
|
|
tray->ModifyTrayIcon(tray->m_Measure->GetRelativeValue());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-02-16 14:46:17 +00:00
|
|
|
case WM_TRAY_DELAYED_REFRESH_ALL:
|
2010-03-29 21:50:05 +00:00
|
|
|
if (Rainmeter)
|
|
|
|
{
|
|
|
|
// Refresh all
|
|
|
|
Rainmeter->RefreshAll();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
2011-02-16 14:46:17 +00:00
|
|
|
case WM_TRAY_DELAYED_EXECUTE:
|
|
|
|
if (Rainmeter && lParam)
|
|
|
|
{
|
|
|
|
// Execute bang
|
|
|
|
WCHAR* bang = (WCHAR*)lParam;
|
|
|
|
Rainmeter->ExecuteCommand(bang, NULL);
|
|
|
|
free(bang); // _wcsdup()
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
case WM_DESTROY:
|
2011-09-28 18:28:35 +00:00
|
|
|
PostQuitMessage(0);
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
|
|
}
|