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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
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"
|
2012-05-05 15:53:33 +00:00
|
|
|
#include "System.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "Error.h"
|
2010-06-21 19:48:00 +00:00
|
|
|
#include "RainmeterQuery.h"
|
2012-05-05 11:43:48 +00:00
|
|
|
#include "resource.h"
|
2011-02-03 15:52:45 +00:00
|
|
|
#include "../Version.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2011-09-17 19:30:31 +00:00
|
|
|
#define RAINMETER_OFFICIAL L"http://rainmeter.net/cms/"
|
2012-10-27 12:17:31 +00:00
|
|
|
#define RAINMETER_HELP L"http://docs.rainmeter.net/"
|
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-11-03 09:27:07 +00:00
|
|
|
enum TIMER
|
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
TIMER_ADDTRAYICON = 1,
|
|
|
|
TIMER_TRAYMEASURE = 3
|
2011-11-03 09:27:07 +00:00
|
|
|
};
|
|
|
|
enum INTERVAL
|
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
INTERVAL_ADDTRAYICON = 3000,
|
|
|
|
INTERVAL_TRAYMEASURE = 1000
|
2011-11-03 09:27:07 +00:00
|
|
|
};
|
|
|
|
|
2011-04-19 00:02:00 +00:00
|
|
|
const UINT WM_TASKBARCREATED = ::RegisterWindowMessage(L"TaskbarCreated");
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
using namespace Gdiplus;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
TrayWindow::TrayWindow() :
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Icon(),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_Measure(),
|
|
|
|
m_MeterType(TRAY_METER_TYPE_HISTOGRAM),
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Color1(0, 100, 0),
|
|
|
|
m_Color2(0, 255, 0),
|
2011-01-29 00:11:01 +00:00
|
|
|
m_Bitmap(),
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Values(),
|
|
|
|
m_Pos(),
|
2012-05-05 11:43:48 +00:00
|
|
|
m_Notification(TRAY_NOTIFICATION_NONE),
|
2012-10-25 09:26:46 +00:00
|
|
|
m_TrayContextMenuEnabled(true),
|
2012-05-05 11:49:22 +00:00
|
|
|
m_IconEnabled(true)
|
2012-05-05 12:59:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
TrayWindow::~TrayWindow()
|
2012-05-05 12:59:35 +00:00
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
KillTimer(m_Window, TIMER_ADDTRAYICON);
|
|
|
|
KillTimer(m_Window, TIMER_TRAYMEASURE);
|
2012-05-05 12:59:35 +00:00
|
|
|
RemoveTrayIcon();
|
|
|
|
|
|
|
|
delete m_Bitmap;
|
|
|
|
delete m_Measure;
|
|
|
|
|
|
|
|
for (size_t i = 0, isize = m_Icons.size(); i < isize; ++i)
|
|
|
|
{
|
|
|
|
DestroyIcon(m_Icons[i]);
|
|
|
|
}
|
|
|
|
m_Icons.clear();
|
|
|
|
|
|
|
|
if (m_Window) DestroyWindow(m_Window);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::Initialize()
|
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;
|
2013-06-13 14:20:27 +00:00
|
|
|
wc.hInstance = GetRainmeter().GetModuleInstance();
|
2009-02-10 18:37:48 +00:00
|
|
|
wc.lpszClassName = L"RainmeterTrayClass";
|
2012-05-05 15:53:33 +00:00
|
|
|
wc.hIcon = GetIcon(IDI_RAINMETER);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
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",
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr,
|
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,
|
2013-05-31 14:28:39 +00:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2012-05-05 12:59:35 +00:00
|
|
|
wc.hInstance,
|
2009-02-10 18:37:48 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
bool TrayWindow::AddTrayIcon()
|
2011-03-29 19:21:57 +00:00
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
|
|
|
tnid.hWnd = m_Window;
|
|
|
|
tnid.uID = IDI_TRAY;
|
|
|
|
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
|
|
|
tnid.uCallbackMessage = WM_TRAY_NOTIFYICON;
|
|
|
|
tnid.hIcon = m_Icon;
|
|
|
|
wcsncpy_s(tnid.szTip, APPNAME, _TRUNCATE);
|
|
|
|
|
|
|
|
return (Shell_NotifyIcon(NIM_ADD, &tnid) || GetLastError() != ERROR_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
bool TrayWindow::IsTrayIconReady()
|
2012-08-05 14:37:45 +00:00
|
|
|
{
|
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
|
|
|
tnid.hWnd = m_Window;
|
|
|
|
tnid.uID = IDI_TRAY;
|
|
|
|
|
2013-12-23 19:42:31 +00:00
|
|
|
return Shell_NotifyIcon(NIM_MODIFY, &tnid) != FALSE;
|
2012-08-05 14:37:45 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::TryAddTrayIcon()
|
2012-08-05 14:37:45 +00:00
|
|
|
{
|
|
|
|
if (IsTrayIconReady())
|
|
|
|
{
|
|
|
|
ModifyTrayIcon(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
if (m_Icon)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
DestroyIcon(m_Icon);
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Icon = nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Icon = CreateTrayIcon(0);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-08-05 14:37:45 +00:00
|
|
|
if (!AddTrayIcon())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetTimer(m_Window, TIMER_ADDTRAYICON, INTERVAL_ADDTRAYICON, nullptr);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::CheckTrayIcon()
|
2011-03-29 19:21:57 +00:00
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
if (IsTrayIconReady() || AddTrayIcon())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
KillTimer(m_Window, TIMER_ADDTRAYICON);
|
|
|
|
}
|
|
|
|
}
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::RemoveTrayIcon()
|
2012-08-05 14:37:45 +00:00
|
|
|
{
|
|
|
|
NOTIFYICONDATA tnid = {sizeof(NOTIFYICONDATA)};
|
|
|
|
tnid.hWnd = m_Window;
|
|
|
|
tnid.uID = IDI_TRAY;
|
|
|
|
tnid.uFlags = 0;
|
|
|
|
|
|
|
|
Shell_NotifyIcon(NIM_DELETE, &tnid);
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-08-05 14:37:45 +00:00
|
|
|
if (m_Icon)
|
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
DestroyIcon(m_Icon);
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Icon = nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::ModifyTrayIcon(double value)
|
2011-03-29 19:21:57 +00:00
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
if (m_Icon)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
DestroyIcon(m_Icon);
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Icon = nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Icon = 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;
|
2012-05-05 11:49:22 +00:00
|
|
|
tnid.hIcon = m_Icon;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-04-06 12:28:39 +00:00
|
|
|
Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
HICON TrayWindow::CreateTrayIcon(double value)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
if (m_Measure != nullptr)
|
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
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Values[m_Pos] = value;
|
|
|
|
m_Pos = (m_Pos + 1) % TRAYICON_SIZE;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
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;
|
2012-05-05 11:49:22 +00:00
|
|
|
points[i + 1].Y = (int)(TRAYICON_SIZE * (1.0 - m_Values[(m_Pos + i) % TRAYICON_SIZE]));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
SolidBrush brush(m_Color1);
|
2009-02-10 18:37:48 +00:00
|
|
|
graphics.FillRectangle(&brush, 0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
SolidBrush brush2(m_Color2);
|
2009-02-10 18:37:48 +00:00
|
|
|
graphics.FillPolygon(&brush2, points, TRAYICON_SIZE + 2);
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
HICON icon = nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
trayBitmap.GetHICON(&icon);
|
|
|
|
return icon;
|
|
|
|
}
|
2012-05-05 11:49:22 +00:00
|
|
|
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || !m_Icons.empty()))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-05-05 11:49:22 +00:00
|
|
|
if (!m_Icons.empty())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
size_t frame = 0;
|
2012-05-05 11:49:22 +00:00
|
|
|
size_t frameCount = m_Icons.size();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
// Select the correct frame linearly
|
|
|
|
frame = (size_t)(value * frameCount);
|
|
|
|
frame = min((frameCount - 1), frame);
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
return CopyIcon(m_Icons[frame]);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
HICON icon = nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
trayBitmap.GetHICON(&icon);
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-30 19:10:55 +00:00
|
|
|
// Return the default icon if there is no valid measure
|
2012-05-05 15:53:33 +00:00
|
|
|
return GetIcon(IDI_TRAY);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text)
|
2012-05-05 11:43:48 +00:00
|
|
|
{
|
|
|
|
if (m_Notification == TRAY_NOTIFICATION_NONE)
|
|
|
|
{
|
|
|
|
NOTIFYICONDATA nid = {sizeof(NOTIFYICONDATA)};
|
|
|
|
nid.hWnd = m_Window;
|
|
|
|
nid.uID = IDI_TRAY;
|
|
|
|
nid.uFlags = NIF_INFO;
|
|
|
|
nid.uTimeout = 30000;
|
|
|
|
nid.dwInfoFlags = NIIF_USER;
|
|
|
|
wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE);
|
|
|
|
wcsncpy_s(nid.szInfo, text, _TRUNCATE);
|
2012-05-05 12:48:41 +00:00
|
|
|
|
2013-03-12 15:57:18 +00:00
|
|
|
if (Platform::IsAtLeastWin7())
|
2012-05-05 15:53:33 +00:00
|
|
|
{
|
|
|
|
nid.dwInfoFlags |= NIIF_LARGE_ICON;
|
|
|
|
nid.hBalloonIcon = GetIcon(IDI_RAINMETER, true);
|
|
|
|
}
|
|
|
|
|
2012-05-05 12:48:41 +00:00
|
|
|
if (Shell_NotifyIcon(NIM_MODIFY, &nid))
|
|
|
|
{
|
|
|
|
m_Notification = id;
|
|
|
|
}
|
2012-05-05 11:43:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::ShowWelcomeNotification()
|
2012-05-05 11:43:48 +00:00
|
|
|
{
|
|
|
|
ShowNotification(TRAY_NOTIFICATION_WELCOME, GetString(ID_STR_WELCOME), GetString(ID_STR_CLICKTOMANAGE));
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::ShowUpdateNotification(const WCHAR* newVersion)
|
2012-05-05 11:43:48 +00:00
|
|
|
{
|
|
|
|
std::wstring text = GetFormattedString(ID_STR_CLICKTODOWNLOAD, newVersion);
|
|
|
|
ShowNotification(TRAY_NOTIFICATION_UPDATE, GetString(ID_STR_UPDATEAVAILABLE), text.c_str());
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::SetTrayIcon(bool enabled)
|
2012-11-12 20:02:01 +00:00
|
|
|
{
|
2012-11-13 14:11:43 +00:00
|
|
|
enabled ? TryAddTrayIcon() : RemoveTrayIcon();
|
|
|
|
m_IconEnabled = enabled;
|
2012-11-12 20:02:01 +00:00
|
|
|
|
2012-11-13 14:11:43 +00:00
|
|
|
// Save to Rainmeter.ini.
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::wstring& iniFile = GetRainmeter().GetIniFile();
|
2013-05-31 14:28:39 +00:00
|
|
|
WritePrivateProfileString(L"Rainmeter", L"TrayIcon", enabled ? nullptr : L"0", iniFile.c_str());
|
2012-11-12 20:02:01 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void TrayWindow::ReadOptions(ConfigParser& parser)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-15 16:54:47 +00:00
|
|
|
// Clear old Settings
|
2012-08-05 14:37:45 +00:00
|
|
|
KillTimer(m_Window, TIMER_ADDTRAYICON);
|
|
|
|
KillTimer(m_Window, TIMER_TRAYMEASURE);
|
2010-12-21 04:49:01 +00:00
|
|
|
|
2010-12-06 08:59:55 +00:00
|
|
|
delete m_Measure;
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Measure = nullptr;
|
2010-12-06 08:59:55 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
delete m_Bitmap;
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Bitmap = nullptr;
|
2011-07-15 16:54:47 +00:00
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
std::vector<HICON>::const_iterator iter = m_Icons.begin();
|
|
|
|
for ( ; iter != m_Icons.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
DestroyIcon((*iter));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Icons.clear();
|
2009-02-10 18:37:48 +00:00
|
|
|
|
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
|
2013-07-31 10:36:53 +00:00
|
|
|
m_IconEnabled = parser.ReadBool(L"Rainmeter", L"TrayIcon", true);
|
2012-05-05 11:49:22 +00:00
|
|
|
if (m_IconEnabled)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
const 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
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
ConfigParser* oldParser = GetRainmeter().GetCurrentParser();
|
|
|
|
GetRainmeter().SetCurrentParser(&parser);
|
2011-07-15 16:54:47 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Measure = Measure::Create(measureName.c_str(), nullptr, L"TrayMeasure");
|
2012-08-12 14:02:08 +00:00
|
|
|
if (m_Measure)
|
2011-07-15 16:54:47 +00:00
|
|
|
{
|
2012-08-12 14:02:08 +00:00
|
|
|
m_Measure->ReadOptions(parser);
|
2010-12-06 08:59:55 +00:00
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetCurrentParser(oldParser);
|
2010-12-06 08:59:55 +00:00
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
|
2011-11-16 16:47:20 +00:00
|
|
|
const WCHAR* type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE").c_str();
|
|
|
|
if (_wcsicmp(type, 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-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(type, L"HISTOGRAM") == 0)
|
2011-07-15 16:54:47 +00:00
|
|
|
{
|
|
|
|
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
2012-05-05 11:49:22 +00:00
|
|
|
m_Color1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color::MakeARGB(255, 0, 100, 0));
|
|
|
|
m_Color2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color::MakeARGB(255, 0, 255, 0));
|
2011-07-15 16:54:47 +00:00
|
|
|
}
|
2011-11-16 16:47:20 +00:00
|
|
|
else if (_wcsicmp(type, L"BITMAP") == 0)
|
2011-07-15 16:54:47 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
imageName.insert(0, GetRainmeter().GetSkinPath());
|
2011-11-21 17:39:09 +00:00
|
|
|
const WCHAR* imagePath = imageName.c_str();
|
|
|
|
if (_wcsicmp(imagePath + (imageName.size() - 4), L".ico") == 0)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
int count = 1;
|
2013-05-31 14:28:39 +00:00
|
|
|
HICON hIcon = nullptr;
|
2011-11-16 16:47:20 +00:00
|
|
|
|
|
|
|
// Load the icons
|
|
|
|
do
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-16 16:47:20 +00:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2011-11-21 17:39:09 +00:00
|
|
|
_snwprintf_s(buffer, _TRUNCATE, imagePath, count++);
|
2011-11-16 16:47:20 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
hIcon = (HICON)LoadImage(nullptr, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
|
2012-05-05 11:49:22 +00:00
|
|
|
if (hIcon) m_Icons.push_back(hIcon);
|
2011-11-21 17:39:09 +00:00
|
|
|
if (wcscmp(imagePath, buffer) == 0) break;
|
2011-07-15 16:54:47 +00:00
|
|
|
}
|
2013-05-31 14:28:39 +00:00
|
|
|
while(hIcon != nullptr);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 11:49:22 +00:00
|
|
|
if (m_Icons.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-11-21 17:39:09 +00:00
|
|
|
m_Bitmap = new Bitmap(imagePath);
|
2011-07-15 16:54:47 +00:00
|
|
|
Status status = m_Bitmap->GetLastStatus();
|
|
|
|
if (Ok != status)
|
|
|
|
{
|
|
|
|
delete m_Bitmap;
|
2013-05-31 14:28:39 +00:00
|
|
|
m_Bitmap = nullptr;
|
2013-05-30 14:19:42 +00:00
|
|
|
LogWarningF(L"Bitmap image not found: %s", imagePath);
|
2011-07-15 16:54:47 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-07-15 16:54:47 +00:00
|
|
|
else
|
|
|
|
{
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"No such TrayMeter: %s", type);
|
2011-07-15 16:54:47 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-08-05 14:37:45 +00:00
|
|
|
TryAddTrayIcon();
|
2010-12-21 04:49:01 +00:00
|
|
|
|
|
|
|
if (m_Measure)
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
SetTimer(m_Window, TIMER_TRAYMEASURE, INTERVAL_TRAYMEASURE, nullptr); // Update the tray once per sec
|
2010-12-21 04:49:01 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
LRESULT CALLBACK TrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
TrayWindow* tray = GetRainmeter().GetTrayWindow();
|
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:
|
2013-02-06 09:55:45 +00:00
|
|
|
switch (wParam)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
case IDM_MANAGE:
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::Open();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_ABOUT:
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogAbout::Open();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_SHOW_HELP:
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(RAINMETER_HELP);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_NEW_VERSION:
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(RAINMETER_OFFICIAL);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_REFRESH:
|
2013-06-13 14:20:27 +00:00
|
|
|
PostMessage(GetRainmeter().GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)nullptr, (LPARAM)nullptr);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_SHOWLOGFILE:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowLogFile();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_STARTLOG:
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().StartLogFile();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_STOPLOG:
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().StopLogFile();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_DELETELOGFILE:
|
2013-06-13 14:22:42 +00:00
|
|
|
GetLogger().DeleteLogFile();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_DEBUGLOG:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetDebug(!GetRainmeter().GetDebug());
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_DISABLEDRAG:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().SetDisableDragging(!GetRainmeter().GetDisableDragging());
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_EDITCONFIG:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().EditSettings();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_QUIT:
|
2012-05-05 12:59:35 +00:00
|
|
|
PostQuitMessage(0);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDM_OPENSKINSFOLDER:
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().OpenSkinFolder();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
2012-05-05 12:59:35 +00:00
|
|
|
|
2013-02-06 09:55:45 +00:00
|
|
|
default:
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
UINT mID = wParam & 0x0FFFF;
|
2012-10-03 21:59:49 +00:00
|
|
|
|
2013-02-06 09:55:45 +00:00
|
|
|
if (mID >= ID_THEME_FIRST && mID <= ID_THEME_LAST)
|
2012-10-03 21:59:49 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
int pos = mID - ID_THEME_FIRST;
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::vector<std::wstring>& layouts = GetRainmeter().GetAllLayouts();
|
2013-02-06 09:55:45 +00:00
|
|
|
if (pos >= 0 && pos < (int)layouts.size())
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().LoadLayout(layouts[pos]);
|
2013-02-06 09:55:45 +00:00
|
|
|
}
|
2012-10-03 21:59:49 +00:00
|
|
|
}
|
2013-02-06 09:55:45 +00:00
|
|
|
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
|
2012-10-03 21:59:49 +00:00
|
|
|
{
|
2013-06-16 16:14:59 +00:00
|
|
|
GetRainmeter().ToggleSkinWithID(mID);
|
2012-10-03 21:59:49 +00:00
|
|
|
}
|
2013-02-06 09:55:45 +00:00
|
|
|
else
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
// Forward the message to correct window
|
|
|
|
int index = (int)(wParam >> 16);
|
2013-06-13 14:20:27 +00:00
|
|
|
const std::map<std::wstring, MeterWindow*>& windows = GetRainmeter().GetAllMeterWindows();
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
if (index < (int)windows.size())
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
std::map<std::wstring, MeterWindow*>::const_iterator iter = windows.begin();
|
2013-02-06 09:55:45 +00:00
|
|
|
for ( ; iter != windows.end(); ++iter)
|
2012-10-03 21:59:49 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
--index;
|
|
|
|
if (index < 0)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
MeterWindow* meterWindow = (*iter).second;
|
2013-05-31 14:28:39 +00:00
|
|
|
SendMessage(meterWindow->GetWindow(), WM_COMMAND, mID, 0);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-03 21:59:49 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2012-10-25 09:26:46 +00:00
|
|
|
break; // Don't send WM_COMMANDS any further
|
2009-02-10 18:37:48 +00:00
|
|
|
|
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;
|
2013-02-06 09:55:45 +00:00
|
|
|
LPCWSTR bang;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-02-06 09:55:45 +00:00
|
|
|
// Check TrayExecute actions
|
2011-08-28 10:58:26 +00:00
|
|
|
switch (uMouseMsg)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
case WM_MBUTTONDOWN:
|
2013-06-13 14:20:27 +00:00
|
|
|
bang = GetRainmeter().GetTrayExecuteM().c_str();
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDOWN:
|
2013-06-13 14:20:27 +00:00
|
|
|
bang = GetRainmeter().GetTrayExecuteR().c_str();
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_MBUTTONDBLCLK:
|
2013-06-13 14:20:27 +00:00
|
|
|
bang = GetRainmeter().GetTrayExecuteDM().c_str();
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONDBLCLK:
|
2013-06-13 14:20:27 +00:00
|
|
|
bang = GetRainmeter().GetTrayExecuteDR().c_str();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bang = L"";
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-02-06 09:55:45 +00:00
|
|
|
if (*bang &&
|
2012-10-25 09:26:46 +00:00
|
|
|
!IsCtrlKeyDown()) // Ctrl is pressed, so only run default action
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ExecuteCommand(bang, nullptr);
|
2012-10-25 09:26:46 +00:00
|
|
|
tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN);
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
// Run default UI action
|
|
|
|
switch (uMouseMsg)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
case WM_RBUTTONDOWN:
|
2012-10-25 09:26:46 +00:00
|
|
|
tray->m_TrayContextMenuEnabled = true;
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_RBUTTONUP:
|
2012-10-25 09:26:46 +00:00
|
|
|
if (tray->m_TrayContextMenuEnabled)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
POINT pos = System::GetCursorPosition();
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowContextMenu(pos, nullptr);
|
2012-10-25 09:26:46 +00:00
|
|
|
}
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_LBUTTONDBLCLK:
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::Open();
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NIN_BALLOONUSERCLICK:
|
2012-05-05 11:43:48 +00:00
|
|
|
if (tray->m_Notification == TRAY_NOTIFICATION_WELCOME)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
DialogManage::Open();
|
2012-05-05 11:43:48 +00:00
|
|
|
}
|
|
|
|
else if (tray->m_Notification == TRAY_NOTIFICATION_UPDATE)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
CommandHandler::RunFile(RAINMETER_OFFICIAL);
|
2012-05-05 11:43:48 +00:00
|
|
|
}
|
|
|
|
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NIN_BALLOONHIDE:
|
|
|
|
case NIN_BALLOONTIMEOUT:
|
2012-05-05 11:43:48 +00:00
|
|
|
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
2013-02-06 09:55:45 +00:00
|
|
|
break;
|
2012-05-05 11:43:48 +00:00
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-06-20 20:52:52 +00:00
|
|
|
case WM_QUERY_RAINMETER:
|
2011-11-08 10:32:57 +00:00
|
|
|
if (IsWindow((HWND)lParam))
|
2010-06-20 20:52:52 +00:00
|
|
|
{
|
2012-02-03 12:48:33 +00:00
|
|
|
auto sendCopyData = [&](const std::wstring& data)
|
2010-06-20 20:52:52 +00:00
|
|
|
{
|
2012-02-03 12:48:33 +00:00
|
|
|
COPYDATASTRUCT cds;
|
|
|
|
cds.dwData = wParam;
|
2012-02-14 17:00:07 +00:00
|
|
|
cds.cbData = (DWORD)((data.length() + 1) * sizeof(WCHAR));
|
2012-02-03 12:48:33 +00:00
|
|
|
cds.lpData = (PVOID)data.c_str();
|
2010-06-20 20:52:52 +00:00
|
|
|
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
2012-02-03 12:48:33 +00:00
|
|
|
};
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2013-02-06 09:55:45 +00:00
|
|
|
switch (wParam)
|
2012-02-03 12:48:33 +00:00
|
|
|
{
|
2013-02-06 09:55:45 +00:00
|
|
|
case RAINMETER_QUERY_ID_SKINS_PATH:
|
2013-06-13 14:20:27 +00:00
|
|
|
sendCopyData(GetRainmeter().GetSkinPath());
|
2010-06-20 20:52:52 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_SETTINGS_PATH:
|
2013-06-13 14:20:27 +00:00
|
|
|
sendCopyData(GetRainmeter().GetSettingsPath());
|
2010-06-20 20:52:52 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_PLUGINS_PATH:
|
2013-06-13 14:20:27 +00:00
|
|
|
sendCopyData(GetRainmeter().GetPluginPath());
|
2010-06-20 20:52:52 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_PROGRAM_PATH:
|
2013-06-13 14:20:27 +00:00
|
|
|
sendCopyData(GetRainmeter().GetPath());
|
2010-06-28 22:30:20 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_LOG_PATH:
|
2013-06-13 14:22:42 +00:00
|
|
|
sendCopyData(GetLogger().GetLogFilePath());
|
2010-06-28 22:30:20 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_CONFIG_EDITOR:
|
2013-06-13 14:20:27 +00:00
|
|
|
sendCopyData(GetRainmeter().GetSkinEditor());
|
2010-06-28 22:30:20 +00:00
|
|
|
return 0;
|
2013-02-06 09:55:45 +00:00
|
|
|
|
|
|
|
case RAINMETER_QUERY_ID_IS_DEBUGGING:
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
BOOL debug = GetRainmeter().GetDebug();
|
2013-02-06 09:55:45 +00:00
|
|
|
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
|
|
|
|
}
|
2010-06-28 22:30:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case WM_COPYDATA:
|
|
|
|
{
|
2011-12-09 08:40:19 +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
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
LPCWSTR folderPath = (LPCWSTR)cds->lpData;
|
2013-06-13 14:20:27 +00:00
|
|
|
MeterWindow* mw = GetRainmeter().GetMeterWindow(folderPath);
|
2013-05-31 14:28:39 +00:00
|
|
|
return (mw) ? (LRESULT)mw->GetWindow() : 0;
|
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:
|
2012-08-05 14:37:45 +00:00
|
|
|
if (wParam == TIMER_TRAYMEASURE)
|
|
|
|
{
|
|
|
|
if (tray->m_Measure)
|
|
|
|
{
|
|
|
|
tray->m_Measure->Update();
|
|
|
|
tray->ModifyTrayIcon(tray->m_Measure->GetRelativeValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (wParam == TIMER_ADDTRAYICON)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-08-05 14:37:45 +00:00
|
|
|
tray->CheckTrayIcon();
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
2011-09-28 18:28:35 +00:00
|
|
|
PostQuitMessage(0);
|
2009-02-10 18:37:48 +00:00
|
|
|
break;
|
2011-12-09 08:40:19 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
if (uMsg == WM_TASKBARCREATED)
|
|
|
|
{
|
2012-05-05 12:59:35 +00:00
|
|
|
if (tray->IsTrayIconEnabled())
|
2011-12-09 08:40:19 +00:00
|
|
|
{
|
|
|
|
tray->RemoveTrayIcon();
|
2012-08-05 14:37:45 +00:00
|
|
|
tray->TryAddTrayIcon();
|
2011-12-09 08:40:19 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-25 09:26:46 +00:00
|
|
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-10-25 09:26:46 +00:00
|
|
|
return 0;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|