From 8a2523a14f4a72cb0228d6de9db4113df07f6628 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 22 Sep 2007 09:08:48 +0000 Subject: [PATCH] kes Add code to handle tray monitor separated from Win32 FD. kes Fix display of Win32 tray monitor after reboot. Fixes bug #952. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5623 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/win32/libwin32/main.cpp | 38 +++++++++++++++++++++++ bacula/src/win32/libwin32/trayMonitor.cpp | 23 +++++++++++--- bacula/src/win32/libwin32/trayMonitor.h | 1 + bacula/technotes-2.3 | 3 ++ 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/bacula/src/win32/libwin32/main.cpp b/bacula/src/win32/libwin32/main.cpp index 8f309c078a..f7451ac97d 100644 --- a/bacula/src/win32/libwin32/main.cpp +++ b/bacula/src/win32/libwin32/main.cpp @@ -244,6 +244,19 @@ int WINAPI WinMain(HINSTANCE Instance, HINSTANCE /*PrevInstance*/, PSTR CmdLine, return BaculaAppMain(); } +#ifndef HAVE_TRAY_MONITOR +/* Minimalist winproc when don't have tray monitor */ +LRESULT CALLBACK bacWinProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) +{ + switch (iMsg) { + case WM_DESTROY: + PostQuitMessage(0); + return 0; + } + return DefWindowProc(hwnd, iMsg, wParam, lParam); +} +#endif + /* * Called as a thread from BaculaAppMain() @@ -268,6 +281,31 @@ void *Main_Msg_Loop(LPVOID lpwThreadParam) if (monitor == NULL) { PostQuitMessage(0); } + +#else + /* Create a window to handle Windows messages */ + WNDCLASSEX baclass; + + baclass.cbSize = sizeof(baclass); + baclass.style = 0; + baclass.lpfnWndProc = bacWinProc; + baclass.cbClsExtra = 0; + baclass.cbWndExtra = 0; + baclass.hInstance = appInstance; + baclass.hIcon = NULL; + baclass.hCursor = NULL; + baclass.hbrBackground = NULL; + baclass.lpszMenuName = NULL; + baclass.lpszClassName = APP_NAME; + baclass.hIconSm = NULL; + + RegisterClassEx(&baclass); + + if (CreateWindow(APP_NAME, APP_NAME, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, + NULL, NULL, appInstance, NULL) == NULL) { + PostQuitMessage(0); + } #endif /* Now enter the Windows message handling loop until told to quit! */ diff --git a/bacula/src/win32/libwin32/trayMonitor.cpp b/bacula/src/win32/libwin32/trayMonitor.cpp index d6e4ce2386..5124b3b615 100644 --- a/bacula/src/win32/libwin32/trayMonitor.cpp +++ b/bacula/src/win32/libwin32/trayMonitor.cpp @@ -43,6 +43,9 @@ trayMonitor::trayMonitor() { + +// m_tbcreated_msg = RegisterWindowMessage("TaskbarCreated"); + /* Create a window to handle tray icon messages */ WNDCLASSEX trayclass; @@ -72,8 +75,6 @@ trayMonitor::trayMonitor() /* Save our class pointer */ SetWindowLong(m_hwnd, GWL_USERDATA, (LONG)this); - /* Timer to trigger icon updating */ - SetTimer(m_hwnd, 1, 5000, NULL); // Load the icons for the tray m_idle_icon = LoadIcon(appInstance, MAKEINTRESOURCE(IDI_IDLE)); @@ -84,9 +85,13 @@ trayMonitor::trayMonitor() /* Load the menu */ m_hmenu = LoadMenu(appInstance, MAKEINTRESOURCE(IDR_TRAYMENU)); m_visible = false; + m_installed = false; /* Install the icon in the tray */ install(); + + /* Timer to trigger icon updating */ + SetTimer(m_hwnd, 1, 5000, NULL); } trayMonitor::~trayMonitor() @@ -102,8 +107,8 @@ trayMonitor::~trayMonitor() void trayMonitor::install() { - sendMessage(NIM_ADD, bacstat); m_installed = true; + sendMessage(NIM_ADD, bacstat); } void trayMonitor::update(int bacstat) @@ -179,9 +184,10 @@ LRESULT CALLBACK trayMonitor::trayWinProc(HWND hwnd, UINT iMsg, WPARAM wParam, L /* Every five seconds, a timer message causes the icon to update */ case WM_TIMER: if (isAService()) { - mon->update(bacstat); + mon->install(); } - break; + mon->update(bacstat); + break; case WM_CREATE: return 0; @@ -255,6 +261,13 @@ LRESULT CALLBACK trayMonitor::trayWinProc(HWND hwnd, UINT iMsg, WPARAM wParam, L return TRUE; } return TRUE; + + default: + /* Need to redraw tray icon */ +// if (iMsg == mon->m_tbcreated_msg) { +// mon->install(); +// } + break; } return DefWindowProc(hwnd, iMsg, wParam, lParam); diff --git a/bacula/src/win32/libwin32/trayMonitor.h b/bacula/src/win32/libwin32/trayMonitor.h index 77bc2031ae..96b6c16813 100644 --- a/bacula/src/win32/libwin32/trayMonitor.h +++ b/bacula/src/win32/libwin32/trayMonitor.h @@ -52,6 +52,7 @@ public: bool m_visible; bool m_installed; + UINT m_tbcreated_msg; aboutDialog m_about; statusDialog m_status; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index be9f6dfd24..af73dc2112 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,9 @@ Technical notes on version 2.3 General: +22Sep07 +kes Add code to handle tray monitor separated from Win32 FD. +kes Fix display of Win32 tray monitor after reboot. Fixes bug #952. 20Sep07 kes Add missed return in fixing verify bug -- trunk only. ebl Fix a command parser issue causing a director segfault. -- 2.39.5