This commit is contained in:
Birunthan Mohanathas 2012-05-05 15:59:35 +03:00
parent b33d59e9de
commit a93c02ef84
3 changed files with 118 additions and 114 deletions

View File

@ -1033,7 +1033,8 @@ int CRainmeter::Initialize(LPCWSTR szPath)
}
// Tray must exist before configs are read
m_TrayWindow = new CTrayWindow(m_Instance);
m_TrayWindow = new CTrayWindow();
m_TrayWindow->Initialize();
ReloadSettings();

View File

@ -49,7 +49,7 @@ extern CRainmeter* Rainmeter;
using namespace Gdiplus;
CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
CTrayWindow::CTrayWindow() :
m_Icon(),
m_Measure(),
m_MeterType(TRAY_METER_TYPE_HISTOGRAM),
@ -61,29 +61,6 @@ CTrayWindow::CTrayWindow(HINSTANCE instance) : m_Instance(instance),
m_Notification(TRAY_NOTIFICATION_NONE),
m_IconEnabled(true)
{
WNDCLASS wc = {0};
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hInstance = instance;
wc.lpszClassName = L"RainmeterTrayClass";
wc.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_SHARED);
RegisterClass(&wc);
m_Window = CreateWindowEx(
WS_EX_TOOLWINDOW,
L"RainmeterTrayClass",
NULL,
WS_POPUP | WS_DISABLED,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
instance,
this);
SetWindowPos(m_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS);
}
CTrayWindow::~CTrayWindow()
@ -103,6 +80,33 @@ CTrayWindow::~CTrayWindow()
if (m_Window) DestroyWindow(m_Window);
}
void CTrayWindow::Initialize()
{
WNDCLASS wc = {0};
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.hInstance = Rainmeter->GetInstance();
wc.lpszClassName = L"RainmeterTrayClass";
wc.hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), LR_SHARED);
RegisterClass(&wc);
m_Window = CreateWindowEx(
WS_EX_TOOLWINDOW,
L"RainmeterTrayClass",
NULL,
WS_POPUP | WS_DISABLED,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
wc.hInstance,
this);
SetWindowPos(m_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS);
}
void CTrayWindow::AddTrayIcon()
{
if (m_Icon)
@ -437,8 +441,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
switch (uMsg)
{
case WM_COMMAND:
if (tray)
{
if (wParam == IDM_MANAGE)
{
CDialogManage::Open();
@ -534,7 +536,6 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
}
}
}
return 0; // Don't send WM_COMMANDS any further
case WM_TRAY_NOTIFYICON:
@ -660,7 +661,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
return 1;
case WM_TIMER:
if (tray && tray->m_Measure)
if (tray->m_Measure)
{
tray->m_Measure->Update();
tray->ModifyTrayIcon(tray->m_Measure->GetRelativeValue());
@ -674,7 +675,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
default:
if (uMsg == WM_TASKBARCREATED)
{
if (tray && tray->IsTrayIconEnabled())
if (tray->IsTrayIconEnabled())
{
tray->RemoveTrayIcon();
tray->AddTrayIcon();

View File

@ -41,9 +41,11 @@ class CMeasure;
class CTrayWindow
{
public:
CTrayWindow(HINSTANCE instance);
CTrayWindow();
~CTrayWindow();
void Initialize();
void ReadConfig(CConfigParser& parser);
HWND GetWindow() { return m_Window; }
bool IsTrayIconEnabled() { return m_IconEnabled; }