How can Wince pops up a menu

zhaozj2021-02-16  89

Tap-And-Hold (TAH) Gesture, tap the action is the action in which the right button is replaced. The ShrecognizeGesture API is used to determine if there is a bit of message. In direct mode, if you have a bit according to the message, return to GN_CONTEXTMENU, otherwise it returns 0. For the notification mode, send the WM_NOTIFY message to bring GN_ContextMenu to the parent window.

1. #include "Aygshell.h"

2. If the CWND window accepts the message, due to the error of the MFC, it should be processed as follows:

Void CMYWND :: ONLBUTTONDOWN (uint nflags, cpoint point)

{

SHRGINFO SHRGI = {0};

Shrgi.cbsize = sizeof (shrginfo);

Shrgi.hwndclient = m_hwnd;

Shrgi.ptdown.x = Point.x;

Shrgi.ptdown.y = point.y;

Shrgi.dwflags = shrg_returncmd;

IF (GN_ContextMenu == :: ShrecognizegeSture (& Shrgi))

ContextMenu (Point);

Else

DEFAULT ();

}

Void CMYCWND :: ContextMenu (cpoint point)

{

CMenu mnuctxt;

Cmenu * pmenu;

CWND * PWND;

IF (! m_nmenuid)

Return;

IF (Mnuctxt.loadMenu (M_NMENUID))

{

PWND = (m_pwndmenu? m_pwndmenu: AFXGETMAINWND ());

PMenu =

Mnuctxt.getsubmenu (0);

IF (PMenu)

{

ClientToscreen (& Point); Pmenu-> TRACKPOPMENU (TPM_LEFTALIGN,

Point.x, Point.y, PWND);

}

}

}

Be careful not to call CWnd :: ONLBUTTONDOWN (UINT NFLAGS, CPOINT), otherwise due to MFC errors, it will respond twice

3. Exception: CListCtrl, CTREECTRL response is correct, as follows

Begin_MESSAGE_MAP (CMYLISTCTRL, CLISTCTRL)

// {{AFX_MSG_MAP (CMYListCtrl)

ON_WM_LBUTTONDOWN ()

ON_WM_LBUTTONUP ()

ON_NOTIFY_REFLECT (GN_ContextMenu, OnListContextMenu)

.

.

.

//}} AFX_MSG_MAP

END_MESSAGE_MAP ()

// CMylistCtrl :: OnListContextMenu

//

// Handles the List Context Menu

//

Void CmylistCtrl :: OnListContextMenu (NmHDR * PNMHDR, LRESULT * PRESULT)

{

CMenu mnuctxt;

Cmenu * pmenu;

CWND * PWND;

NMRGINFO * PINFO;

IF (! m_nlstmenu)

Return;

IF (Mnuctxt.loadMenu (M_NLStmenu))

{

PWnd = (m_pwndmenu? m_pwndmenu: AFXGETMAINWND ()); pmenu = mnuctxt.getsubmenu (0);

IF (PMenu)

{

UINT UFLAGS;

Cpoint pt;

PINFO = (NMRGINFO *) PNMHDR;

Pt = PINFO-> PTAction;

ScreenToClient (& PT);

M_iitemonum = Hittest (PT, & UFLAGS);

//

// Signal this is a tap and all operation

//

m_btapandhold = rue; pmenu-> TRACKPOPUPMENU (TPM_LEFTALIGN, PINFO-> PTAction.x, PINFO-> PTAction.Y, PWND);

}

}

}

// cmylistctrl :: ONLBUTTONDOWN

//

// Special Handler for WM_LButtondown.

// Check for a tap and cover gesture. Never Trust MFC ...

//

Void CMylistCtrl :: ONLBUTTONDOWN (UINT NFLAGS, CPOINT)

{

m_btapandhold = false;

DEFAULT ();

}

// cmylistctrl :: ONLBUTTONUP

//

// the user released the stylus

//

Void CmylistCtrl :: ONLBUTTONUP (UINT NFLAGS, CPOINT)

{

ClistCtrl :: ONLBUTTONUP (NFLAGS, POINT);

m_btapandhold = false;

}

转载请注明原文地址:https://www.9cbs.com/read-12905.html

New Post(0)