diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2013-05-11 19:26:55 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2013-05-11 19:26:55 +0400 |
commit | 8e6e10c20e3725e34fddbb00c8667632d302209d (patch) | |
tree | e8bf36ed8d4d7e46b3068f45d94a339a7213d833 | |
parent | 2aff5e5f9819e3b5199142c352a76832b7312981 (diff) |
Factor opening the property page into a helper function.
This allows re-using the code for popup menu entries.
-rw-r--r-- | common/DSUtilLite/BaseTrayIcon.cpp | 18 | ||||
-rw-r--r-- | common/DSUtilLite/BaseTrayIcon.h | 2 |
2 files changed, 14 insertions, 6 deletions
diff --git a/common/DSUtilLite/BaseTrayIcon.cpp b/common/DSUtilLite/BaseTrayIcon.cpp index 87a2c01d..95e500b3 100644 --- a/common/DSUtilLite/BaseTrayIcon.cpp +++ b/common/DSUtilLite/BaseTrayIcon.cpp @@ -206,6 +206,17 @@ HRESULT CBaseTrayIcon::CreateTrayIconData() return S_OK; } +HRESULT CBaseTrayIcon::OpenPropPage() +{ + m_bPropPageOpen = TRUE; + RECT desktopRect; + GetWindowRect(GetDesktopWindow(), &desktopRect); + SetWindowPos(m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + CBaseDSPropPage::ShowPropPageDialog(m_pFilter, m_hWnd); + m_bPropPageOpen = FALSE; + return S_OK; +} + static BOOL CALLBACK enumWindowCallback(HWND hwnd, LPARAM lparam) { HWND owner = (HWND)lparam; @@ -233,12 +244,7 @@ LRESULT CALLBACK CBaseTrayIcon::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, switch (trayMsg) { case WM_LBUTTONUP: if (!icon->m_bPropPageOpen) { - icon->m_bPropPageOpen = TRUE; - RECT desktopRect; - GetWindowRect(GetDesktopWindow(), &desktopRect); - SetWindowPos(icon->m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - CBaseDSPropPage::ShowPropPageDialog(icon->m_pFilter, icon->m_hWnd); - icon->m_bPropPageOpen = FALSE; + icon->OpenPropPage(); } else { EnumThreadWindows(GetCurrentThreadId(), enumWindowCallback, (LPARAM)icon->m_hWnd); } diff --git a/common/DSUtilLite/BaseTrayIcon.h b/common/DSUtilLite/BaseTrayIcon.h index d43a008e..062ee1fd 100644 --- a/common/DSUtilLite/BaseTrayIcon.h +++ b/common/DSUtilLite/BaseTrayIcon.h @@ -36,6 +36,8 @@ protected: virtual HMENU GetPopupMenu() { return NULL; } virtual HRESULT ProcessMenuCommand(HMENU hMenu, int cmd) { return E_NOTIMPL; } + HRESULT OpenPropPage(); + private: HRESULT StartMessageThread(); HRESULT RegisterWindowClass(); |