Bugfixes on SysTray integration. Integrates with Application now. Messages are handled by the wndproc of TopLevelWindow

This commit is contained in:
andre@woesten.com 2008-09-03 09:01:42 +00:00
parent f4422e06f7
commit 3aa5ded910
5 changed files with 26 additions and 18 deletions

View File

@ -105,10 +105,10 @@ void MainWindowController::OnMainWindowCreated(Window* window)
// Bind Exit to handler
trayExit->Activated.connect(this, &MainWindowController::OnFileExit);
UINT uidTrayIcon = this->mainWindow.SysTrayManager()->AddIcon(window, icon);
this->mainWindow.SysTrayManager()->SetTooltip(uidTrayIcon, _T("And another test..."));
this->mainWindow.SysTrayManager()->SetPopupMenu(uidTrayIcon, myMenu);
this->mainWindow.SysTrayManager()->ShowBalloon(uidTrayIcon, _T("musikCube 2"), _T("Welcome to musikCube!"), 2);
UINT uidTrayIcon = Application::Instance().SysTrayManager()->AddIcon(Application::Instance().MainWindow(), icon);
Application::Instance().SysTrayManager()->SetTooltip(uidTrayIcon, _T("And another test..."));
Application::Instance().SysTrayManager()->SetPopupMenu(uidTrayIcon, myMenu);
Application::Instance().SysTrayManager()->ShowBalloon(uidTrayIcon, _T("musikCube 2"), _T("Welcome to musikCube!"), 2);
static const int TransportViewHeight = 54;

View File

@ -57,6 +57,7 @@ Application Application::sMainApplication;
, showCommand(NULL)
, mainWindow(NULL)
, appThread(NULL)
, sysTray(NULL)
{
}
@ -127,6 +128,9 @@ void Application::Run(TopLevelWindow& mainWindow)
this->appThread = new ApplicationThread();
this->appThread->Initialize();
this->sysTray = new SysTray;
//
mainWindow.Destroyed.connect(this, &Application::OnMainWindowDestroyed);
//
@ -135,10 +139,15 @@ void Application::Run(TopLevelWindow& mainWindow)
MSG msg;
while (::GetMessage(&msg, NULL, 0, 0) > 0)
{
Application::Instance().SysTrayManager()->WindowProc(msg.message, msg.wParam, msg.lParam);
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
delete this->sysTray;
this->sysTray = NULL;
delete this->appThread;
this->appThread = NULL;
@ -212,4 +221,10 @@ Application::operator HINSTANCE() const
ApplicationThread* Application::Thread()
{
return this->appThread;
}
///\brief Returns the systray manager
SysTray* Application::SysTrayManager() const
{
return this->sysTray;
}

View File

@ -73,7 +73,7 @@ public: // types
///is already running.
class ApplicationAlreadyRunningException: public Exception { };
public: // constructors
public:
/*ctor*/ Application();
public: // methods
@ -86,6 +86,7 @@ public: // methods
const uistring& CommandLine() const;
int ShowCommand() const;
void Terminate() const;
SysTray* SysTrayManager() const;
ApplicationThread* Thread();
public: // operator overloads
@ -101,6 +102,7 @@ private: // instance data
int showCommand;
TopLevelWindow* mainWindow;
ApplicationThread* appThread;
SysTray* sysTray;
private: // class data
static Application sMainApplication;

View File

@ -63,12 +63,10 @@ using namespace win32cpp;
, closed(false)
, modalChild(NULL)
{
this->sysTray = new SysTray;
}
/*dtor*/ TopLevelWindow::~TopLevelWindow()
{
delete this->sysTray;
}
bool TopLevelWindow::RegisterWindowClass()
@ -149,12 +147,6 @@ Size TopLevelWindow::MinimumSize() const
return this->minSize;
}
///\brief Returns the systray manager
SysTray* TopLevelWindow::SysTrayManager()
{
return this->sysTray;
}
///\brief Closes the TopLevelWindow
void TopLevelWindow::Close()
{
@ -197,9 +189,11 @@ LRESULT TopLevelWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lPara
}
return 0;
}
this->SysTrayManager()->WindowProc(message, wParam, lParam);
if(this == Application::Instance().MainWindow()) {
Application::Instance().SysTrayManager()->WindowProc(message, wParam, lParam);
}
return base::WindowProc(message, wParam, lParam);
}

View File

@ -71,8 +71,6 @@ public: // methods
void ShowModal(TopLevelWindow* parent);
void Close();
SysTray* SysTrayManager();
static TopLevelWindow* FindFromAncestor(Window* window);
protected: // methods
@ -88,7 +86,6 @@ protected: // methods
static bool RegisterWindowClass();
private: // instance data
SysTray* sysTray;
uistring windowTitle;
bool closed;
Size minSize;