[RSHELL]
[reactos.git] / base / shell / rshell / CMenuFocusManager.cpp
index 1d556fc..36ef3d0 100644 (file)
@@ -378,6 +378,8 @@ LRESULT CMenuFocusManager::ProcessMouseDown(MSG* msg)
     HWND child;
     int iHitTestResult = -1;
 
+    TRACE("ProcessMouseDown %d %d %d\n", msg->message, msg->wParam, msg->lParam);
+
     // Don't do anything if another window is capturing the mouse.
     HWND cCapture = ::GetCapture();
     if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
@@ -394,12 +396,10 @@ LRESULT CMenuFocusManager::ProcessMouseDown(MSG* msg)
 
     TRACE("MouseDown %d\n", m_isLButtonDown);
 
-    BOOL isTracking = FALSE;
     if (entry)
     {
         ScreenToClient(child, &pt);
         iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt);
-        isTracking = entry->mb->_IsTracking();
 
         if (iHitTestResult >= 0)
         {
@@ -424,6 +424,8 @@ LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
     HWND child;
     int iHitTestResult = -1;
 
+    TRACE("ProcessMouseUp %d %d %d\n", msg->message, msg->wParam, msg->lParam);
+
     // Don't do anything if another window is capturing the mouse.
     HWND cCapture = ::GetCapture();
     if (cCapture && cCapture != m_captureHwnd && m_current->type != TrackedMenuEntry)
@@ -444,12 +446,10 @@ LRESULT CMenuFocusManager::ProcessMouseUp(MSG* msg)
 
     TRACE("MouseUp %d\n", m_isLButtonDown);
 
-    BOOL isTracking = FALSE;
     if (entry)
     {
         ScreenToClient(child, &pt);
         iHitTestResult = SendMessageW(child, TB_HITTEST, 0, (LPARAM) &pt);
-        isTracking = entry->mb->_IsTracking();
 
         if (iHitTestResult >= 0)
         {
@@ -637,6 +637,16 @@ LRESULT CMenuFocusManager::GetMsgHook(INT nCode, WPARAM hookWParam, LPARAM hookL
 
 HRESULT CMenuFocusManager::PlaceHooks()
 {
+    if (m_hMsgFilterHook)
+    {
+        WARN("GETMESSAGE hook already placed!\n");
+        return S_OK;
+    }
+    if (m_hMsgFilterHook)
+    {
+        WARN("MSGFILTER hook already placed!\n");
+        return S_OK;
+    }
     if (m_current->type == TrackedMenuEntry)
     {
         TRACE("Entering MSGFILTER hook...\n");
@@ -667,6 +677,8 @@ HRESULT CMenuFocusManager::UpdateFocus()
     HRESULT hr;
     StackEntry * old = m_current;
 
+    TRACE("UpdateFocus\n");
+
     if (old)
         SetCapture(NULL);
 
@@ -753,6 +765,10 @@ HRESULT CMenuFocusManager::UpdateFocus()
 
 HRESULT CMenuFocusManager::PushMenuBar(CMenuBand * mb)
 {
+    DbgPrint("PushMenuBar %p\n", mb);
+
+    mb->AddRef();
+
     _ASSERT(m_bandCount == 0);
 
     HRESULT hr = PushToArray(MenuBarEntry, mb, NULL);
@@ -764,6 +780,10 @@ HRESULT CMenuFocusManager::PushMenuBar(CMenuBand * mb)
 
 HRESULT CMenuFocusManager::PushMenuPopup(CMenuBand * mb)
 {
+    DbgPrint("PushTrackedPopup %p\n", mb);
+
+    mb->AddRef();
+
     _ASSERT(!m_current || m_current->type != TrackedMenuEntry);
 
     HRESULT hr = PushToArray(MenuPopupEntry, mb, NULL);
@@ -783,6 +803,8 @@ HRESULT CMenuFocusManager::PushMenuPopup(CMenuBand * mb)
 
 HRESULT CMenuFocusManager::PushTrackedPopup(HMENU popup)
 {
+    DbgPrint("PushTrackedPopup %p\n", popup);
+
     _ASSERT(m_bandCount > 0);
     _ASSERT(!m_current || m_current->type != TrackedMenuEntry);
 
@@ -790,7 +812,7 @@ HRESULT CMenuFocusManager::PushTrackedPopup(HMENU popup)
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
 
-    TRACE("PushTrackedPopup %p\n", popup);
+    DbgPrint("PushTrackedPopup %p\n", popup);
     m_selectedMenu = popup;
     m_selectedItem = -1;
     m_selectedItemFlags = 0;
@@ -804,6 +826,13 @@ HRESULT CMenuFocusManager::PopMenuBar(CMenuBand * mb)
     CMenuBand * mbc;
     HRESULT hr;
 
+    DbgPrint("PopMenuBar %p\n", mb);
+
+    if (m_current == m_entryUnderMouse)
+    {
+        m_entryUnderMouse = NULL;
+    }
+
     hr = PopFromArray(&type, &mbc, NULL);
     if (FAILED_UNEXPECTEDLY(hr))
     {
@@ -820,6 +849,8 @@ HRESULT CMenuFocusManager::PopMenuBar(CMenuBand * mb)
 
     mbc->_SetParentBand(NULL);
 
+    mbc->Release();
+
     hr = UpdateFocus();
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
@@ -839,6 +870,13 @@ HRESULT CMenuFocusManager::PopMenuPopup(CMenuBand * mb)
     CMenuBand * mbc;
     HRESULT hr;
 
+    DbgPrint("PopMenuPopup %p\n", mb);
+
+    if (m_current == m_entryUnderMouse)
+    {
+        m_entryUnderMouse = NULL;
+    }
+
     hr = PopFromArray(&type, &mbc, NULL);
     if (FAILED_UNEXPECTEDLY(hr))
     {
@@ -855,6 +893,8 @@ HRESULT CMenuFocusManager::PopMenuPopup(CMenuBand * mb)
 
     mbc->_SetParentBand(NULL);
 
+    mbc->Release();
+
     hr = UpdateFocus();
     if (FAILED_UNEXPECTEDLY(hr))
         return hr;
@@ -874,6 +914,8 @@ HRESULT CMenuFocusManager::PopTrackedPopup(HMENU popup)
     HMENU hmenu;
     HRESULT hr;
 
+    DbgPrint("PopTrackedPopup %p\n", popup);
+
     hr = PopFromArray(&type, NULL, &hmenu);
     if (FAILED_UNEXPECTEDLY(hr))
     {