From 777f37e0ccea2836804085fc7d0f5d9666a787f9 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Mon, 10 Apr 2006 01:17:49 +0000
Subject: [PATCH] don't generate wxEVT_CONTEXT_MENU messages for right clicks
 in the list control header

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/msw/listctrl.cpp | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp
index b4d348ac46..3524895a5f 100644
--- a/src/msw/listctrl.cpp
+++ b/src/msw/listctrl.cpp
@@ -2695,15 +2695,26 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
 WXLRESULT
 wxListCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
 {
-#ifdef WM_PRINT
-    if ( nMsg == WM_PRINT )
+    switch ( nMsg )
     {
-        // we should bypass our own WM_PRINT handling as we don't handle
-        // PRF_CHILDREN flag, so leave it to the native control itself
-        return MSWDefWindowProc(nMsg, wParam, lParam);
-    }
+#ifdef WM_PRINT
+        case WM_PRINT:
+            // we should bypass our own WM_PRINT handling as we don't handle
+            // PRF_CHILDREN flag, so leave it to the native control itself
+            return MSWDefWindowProc(nMsg, wParam, lParam);
 #endif // WM_PRINT
 
+        case WM_CONTEXTMENU:
+            // because this message is propagated upwards the child-parent
+            // chain, we get it for the right clicks on the header window but
+            // this is confusing in wx as right clicking there already
+            // generates a separate wxEVT_COMMAND_LIST_COL_RIGHT_CLICK event
+            // so just ignore them
+            if ( (HWND)wParam == ListView_GetHeader(GetHwnd()) )
+                return 0;
+            //else: break
+    }
+
     return wxControl::MSWWindowProc(nMsg, wParam, lParam);
 }
 
-- 
2.47.2