mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed tray notifications to use 32x32 icon on Vista+
This commit is contained in:
parent
a93c02ef84
commit
8d04988c12
@ -257,7 +257,7 @@ INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
|||||||
HWND item = GetDlgItem(m_Window, IDCLOSE);
|
HWND item = GetDlgItem(m_Window, IDCLOSE);
|
||||||
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
||||||
|
|
||||||
HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
HICON hIcon = GetIcon(IDI_RAINMETER);
|
||||||
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
||||||
|
|
||||||
if (*GetString(ID_STR_ISRTL) == L'1')
|
if (*GetString(ID_STR_ISRTL) == L'1')
|
||||||
@ -1084,7 +1084,7 @@ void CDialogAbout::CTabVersion::Initialize()
|
|||||||
m_Initialized = true;
|
m_Initialized = true;
|
||||||
|
|
||||||
HWND item = GetDlgItem(m_Window, IDC_ABOUTVERSION_RAINMETER_ICON);
|
HWND item = GetDlgItem(m_Window, IDC_ABOUTVERSION_RAINMETER_ICON);
|
||||||
HICON icon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, 32, 32, LR_SHARED);
|
HICON icon = GetIcon(IDI_RAINMETER, true);
|
||||||
Static_SetIcon(item, icon);
|
Static_SetIcon(item, icon);
|
||||||
|
|
||||||
item = GetDlgItem(m_Window, IDC_ABOUTVERSION_VERSION_TEXT);
|
item = GetDlgItem(m_Window, IDC_ABOUTVERSION_VERSION_TEXT);
|
||||||
|
@ -232,7 +232,7 @@ INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
|
|||||||
HWND item = GetDlgItem(m_Window, IDCLOSE);
|
HWND item = GetDlgItem(m_Window, IDCLOSE);
|
||||||
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);
|
||||||
|
|
||||||
HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
HICON hIcon = GetIcon(IDI_RAINMETER);
|
||||||
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
|
||||||
|
|
||||||
if (*GetString(ID_STR_ISRTL) == L'1')
|
if (*GetString(ID_STR_ISRTL) == L'1')
|
||||||
|
@ -337,6 +337,36 @@ std::wstring GetFormattedString(UINT id, ...)
|
|||||||
return tmpSz;
|
return tmpSz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HICON GetIcon(UINT id, bool large)
|
||||||
|
{
|
||||||
|
typedef HRESULT (WINAPI * FPLOADICONMETRIC)(HINSTANCE hinst, PCWSTR pszName, int lims, HICON* phico);
|
||||||
|
|
||||||
|
HINSTANCE hExe = GetModuleHandle(NULL);
|
||||||
|
HINSTANCE hComctl = GetModuleHandle(L"Comctl32");
|
||||||
|
if (hComctl)
|
||||||
|
{
|
||||||
|
// Try LoadIconMetric for better quality with high DPI
|
||||||
|
FPLOADICONMETRIC loadIconMetric = (FPLOADICONMETRIC)GetProcAddress(hComctl, "LoadIconMetric");
|
||||||
|
if (loadIconMetric)
|
||||||
|
{
|
||||||
|
HICON icon;
|
||||||
|
HRESULT hr = loadIconMetric(hExe, MAKEINTRESOURCE(id), large ? LIM_LARGE : LIM_SMALL, &icon);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (HICON)LoadImage(
|
||||||
|
hExe,
|
||||||
|
MAKEINTRESOURCE(id),
|
||||||
|
IMAGE_ICON,
|
||||||
|
GetSystemMetrics(large ? SM_CXICON : SM_CXSMICON),
|
||||||
|
GetSystemMetrics(large ? SM_CYICON : SM_CYSMICON),
|
||||||
|
LR_SHARED);
|
||||||
|
}
|
||||||
|
|
||||||
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
|
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved)
|
||||||
{
|
{
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
|
@ -54,6 +54,8 @@ void RunCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, bool asAdmin = fals
|
|||||||
WCHAR* GetString(UINT id);
|
WCHAR* GetString(UINT id);
|
||||||
std::wstring GetFormattedString(UINT id, ...);
|
std::wstring GetFormattedString(UINT id, ...);
|
||||||
|
|
||||||
|
HICON GetIcon(UINT id, bool large = false);
|
||||||
|
|
||||||
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);
|
void RmNullCRTInvalidParameterHandler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "Rainmeter.h"
|
#include "Rainmeter.h"
|
||||||
#include "DialogAbout.h"
|
#include "DialogAbout.h"
|
||||||
#include "DialogManage.h"
|
#include "DialogManage.h"
|
||||||
|
#include "System.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
#include "RainmeterQuery.h"
|
#include "RainmeterQuery.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
@ -86,7 +87,7 @@ void CTrayWindow::Initialize()
|
|||||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||||
wc.hInstance = Rainmeter->GetInstance();
|
wc.hInstance = Rainmeter->GetInstance();
|
||||||
wc.lpszClassName = L"RainmeterTrayClass";
|
wc.lpszClassName = L"RainmeterTrayClass";
|
||||||
wc.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_SHARED);
|
wc.hIcon = GetIcon(IDI_RAINMETER);
|
||||||
|
|
||||||
RegisterClass(&wc);
|
RegisterClass(&wc);
|
||||||
|
|
||||||
@ -260,24 +261,7 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the default icon if there is no valid measure
|
// Return the default icon if there is no valid measure
|
||||||
HINSTANCE hExe = GetModuleHandle(NULL);
|
return GetIcon(IDI_TRAY);
|
||||||
HINSTANCE hComctl = GetModuleHandle(L"Comctl32");
|
|
||||||
if (hComctl)
|
|
||||||
{
|
|
||||||
// Try LoadIconMetric for better quality with high DPI
|
|
||||||
FPLOADICONMETRIC loadIconMetric = (FPLOADICONMETRIC)GetProcAddress(hComctl, "LoadIconMetric");
|
|
||||||
if (loadIconMetric)
|
|
||||||
{
|
|
||||||
HICON icon;
|
|
||||||
HRESULT hr = loadIconMetric(hExe, MAKEINTRESOURCE(IDI_TRAY), LIM_SMALL, &icon);
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
{
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (HICON)LoadImage(hExe, MAKEINTRESOURCE(IDI_TRAY), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text)
|
void CTrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text)
|
||||||
@ -290,10 +274,15 @@ void CTrayWindow::ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, con
|
|||||||
nid.uFlags = NIF_INFO;
|
nid.uFlags = NIF_INFO;
|
||||||
nid.uTimeout = 30000;
|
nid.uTimeout = 30000;
|
||||||
nid.dwInfoFlags = NIIF_USER;
|
nid.dwInfoFlags = NIIF_USER;
|
||||||
nid.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, 32, 32, LR_SHARED);
|
|
||||||
wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE);
|
wcsncpy_s(nid.szInfoTitle, title, _TRUNCATE);
|
||||||
wcsncpy_s(nid.szInfo, text, _TRUNCATE);
|
wcsncpy_s(nid.szInfo, text, _TRUNCATE);
|
||||||
|
|
||||||
|
if (CSystem::GetOSPlatform() > OSPLATFORM_VISTA)
|
||||||
|
{
|
||||||
|
nid.dwInfoFlags |= NIIF_LARGE_ICON;
|
||||||
|
nid.hBalloonIcon = GetIcon(IDI_RAINMETER, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (Shell_NotifyIcon(NIM_MODIFY, &nid))
|
if (Shell_NotifyIcon(NIM_MODIFY, &nid))
|
||||||
{
|
{
|
||||||
m_Notification = id;
|
m_Notification = id;
|
||||||
|
@ -23,8 +23,6 @@
|
|||||||
#include <gdiplus.h>
|
#include <gdiplus.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
typedef HRESULT (WINAPI * FPLOADICONMETRIC)(HINSTANCE hinst, PCWSTR pszName, int lims, HICON* phico);
|
|
||||||
|
|
||||||
#define WM_TRAY_NOTIFYICON WM_USER + 101
|
#define WM_TRAY_NOTIFYICON WM_USER + 101
|
||||||
#define TRAYICON_SIZE 16
|
#define TRAYICON_SIZE 16
|
||||||
|
|
||||||
@ -69,11 +67,12 @@ private:
|
|||||||
void ModifyTrayIcon(double value);
|
void ModifyTrayIcon(double value);
|
||||||
HICON CreateTrayIcon(double value);
|
HICON CreateTrayIcon(double value);
|
||||||
|
|
||||||
|
HICON LoadResourceIcon(LPCWSTR name, bool large = false);
|
||||||
|
|
||||||
void ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text);
|
void ShowNotification(TRAY_NOTIFICATION id, const WCHAR* title, const WCHAR* text);
|
||||||
|
|
||||||
HICON m_Icon;
|
HICON m_Icon;
|
||||||
HWND m_Window;
|
HWND m_Window;
|
||||||
HINSTANCE m_Instance;
|
|
||||||
CMeasure* m_Measure;
|
CMeasure* m_Measure;
|
||||||
|
|
||||||
TRAY_METER_TYPE m_MeterType;
|
TRAY_METER_TYPE m_MeterType;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user