]> git.saurik.com Git - wxWidgets.git/commitdiff
Added context menu support under PocketPC
authorJulian Smart <julian@anthemion.co.uk>
Tue, 28 Feb 2006 13:37:23 +0000 (13:37 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 28 Feb 2006 13:37:23 +0000 (13:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/window.h
src/msw/window.cpp

index c11f9fdaaa6db14f480a7c8d7dd9fa88ca787762..01232d1ac9a8d2c9b1e9db3932137082365d61cb 100644 (file)
@@ -137,6 +137,11 @@ public:
     virtual bool UnregisterHotKey(int hotkeyId);
 #endif // wxUSE_HOTKEY
 
+#ifdef __POCKETPC__
+    bool IsContextMenuEnabled() const { return m_contextMenuEnabled; }
+    void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; }
+#endif
+
     // window handle stuff
     // -------------------
 
@@ -502,6 +507,10 @@ private:
     wxPoint     m_pendingPosition;
     wxSize      m_pendingSize;
 
+#ifdef __POCKETPC__
+    bool        m_contextMenuEnabled;
+#endif
+
     DECLARE_DYNAMIC_CLASS(wxWindowMSW)
     DECLARE_NO_COPY_CLASS(wxWindowMSW)
     DECLARE_EVENT_TABLE()
index 3cbd0401678c01cc6e9736c07686db2b139e6d6b..7872678a64da4da7cca18ed3bab2d395063798c9 100644 (file)
 
 #if defined(__WXWINCE__)
     #include "wx/msw/wince/missing.h"
+#ifdef __POCKETPC__
+    #include <windows.h>
+    #include <shellapi.h>
+    #include <ole2.h>
+    #include <aygshell.h>
+#endif
 #endif
 
 #if defined(TME_LEAVE) && defined(WM_MOUSELEAVE)
@@ -487,6 +493,10 @@ void wxWindowMSW::Init()
 
     m_pendingPosition = wxDefaultPosition;
     m_pendingSize = wxDefaultSize;
+
+#ifdef __POCKETPC__
+    m_contextMenuEnabled = false;
+#endif
 }
 
 // Destructor
@@ -2582,6 +2592,35 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
                     wxCHECK_MSG( win, 0,
                                  _T("FindWindowForMouseEvent() returned NULL") );
                 }
+#ifdef __POCKETPC__
+                if (IsContextMenuEnabled() && message == WM_LBUTTONDOWN)
+                {
+                    SHRGINFO shrgi = {0};
+                    
+                    shrgi.cbSize = sizeof(SHRGINFO);
+                    shrgi.hwndClient = (HWND) GetHWND();
+                    shrgi.ptDown.x = x;
+                    shrgi.ptDown.y = y;
+                    
+                    shrgi.dwFlags = SHRG_RETURNCMD;
+                    // shrgi.dwFlags = SHRG_NOTIFYPARENT;
+                    
+                    if (GN_CONTEXTMENU == ::SHRecognizeGesture(&shrgi))
+                    {
+                        wxPoint pt(x, y);
+                        pt = ClientToScreen(pt);
+                        
+                        wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, GetId(), pt);
+                        
+                        evtCtx.SetEventObject(this);
+                        if (GetEventHandler()->ProcessEvent(evtCtx))
+                            processed = true;
+                        else
+                            return MSWDefWindowProc(message, wParam, lParam);
+                    }
+                }
+#endif
+
 #else // !__WXWINCE__
                 wxWindowMSW *win = this;
 #endif // __WXWINCE__/!__WXWINCE__