Added context menu support under PocketPC

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-02-28 13:37:23 +00:00
parent 42b16af462
commit 7d4f65e393
2 changed files with 48 additions and 0 deletions

View File

@@ -137,6 +137,11 @@ public:
virtual bool UnregisterHotKey(int hotkeyId); virtual bool UnregisterHotKey(int hotkeyId);
#endif // wxUSE_HOTKEY #endif // wxUSE_HOTKEY
#ifdef __POCKETPC__
bool IsContextMenuEnabled() const { return m_contextMenuEnabled; }
void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; }
#endif
// window handle stuff // window handle stuff
// ------------------- // -------------------
@@ -502,6 +507,10 @@ private:
wxPoint m_pendingPosition; wxPoint m_pendingPosition;
wxSize m_pendingSize; wxSize m_pendingSize;
#ifdef __POCKETPC__
bool m_contextMenuEnabled;
#endif
DECLARE_DYNAMIC_CLASS(wxWindowMSW) DECLARE_DYNAMIC_CLASS(wxWindowMSW)
DECLARE_NO_COPY_CLASS(wxWindowMSW) DECLARE_NO_COPY_CLASS(wxWindowMSW)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -110,6 +110,12 @@
#if defined(__WXWINCE__) #if defined(__WXWINCE__)
#include "wx/msw/wince/missing.h" #include "wx/msw/wince/missing.h"
#ifdef __POCKETPC__
#include <windows.h>
#include <shellapi.h>
#include <ole2.h>
#include <aygshell.h>
#endif
#endif #endif
#if defined(TME_LEAVE) && defined(WM_MOUSELEAVE) #if defined(TME_LEAVE) && defined(WM_MOUSELEAVE)
@@ -487,6 +493,10 @@ void wxWindowMSW::Init()
m_pendingPosition = wxDefaultPosition; m_pendingPosition = wxDefaultPosition;
m_pendingSize = wxDefaultSize; m_pendingSize = wxDefaultSize;
#ifdef __POCKETPC__
m_contextMenuEnabled = false;
#endif
} }
// Destructor // Destructor
@@ -2582,6 +2592,35 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
wxCHECK_MSG( win, 0, wxCHECK_MSG( win, 0,
_T("FindWindowForMouseEvent() returned NULL") ); _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__ #else // !__WXWINCE__
wxWindowMSW *win = this; wxWindowMSW *win = this;
#endif // __WXWINCE__/!__WXWINCE__ #endif // __WXWINCE__/!__WXWINCE__