Extended CLIstBox control not receiving message to populate Context menu as part of Press and Hold operation in surfacePro device.

  • Thread starter Thread starter ravinalla
  • Start date Start date
R

ravinalla

Guest
We extended CLIstBox MFC class as below. We also override GetGestureStatus as suggested in https://support.microsoft.com/en-in/help/2846829/how-to-enable-tablet-press-and-hold-gesture-in-mfc-application to receive user input as part of touch activity.

class CustomCListBox :public CListBox

{

public:

BOOL CreateEx(DWORD dwExStyle, LPCTSTR lpszClassName,

LPCTSTR lpszWindowName, DWORD dwStyle,

const RECT& rect, CWnd* pParentWnd, UINT nID,

LPVOID lpParam = NULL)

{

return CListBox::CreateEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, lpParam);

}

private:

virtual ULONG GetGestureStatus(CPoint ptTouch);

void OnContextMenu(CWnd* pWnd, CPoint point);

DECLARE_MESSAGE_MAP()

};

BEGIN_MESSAGE_MAP(CustomCListBox, CListBox)

ON_WM_CONTEXTMENU()

END_MESSAGE_MAP()

ULONG CustomCListBox::GetGestureStatus(CPoint /*ptTouch*/)

{

return 0;

}

void CustomCListBox::OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/)

{

AfxMessageBox(L"CustomCListBox::OnContextMenu message recived.");

}

We created control as below using above custom control

CustomCListBox *m_List;

DWORD extendedstyle = WS_EX_CLIENTEDGE;

DWORD style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;

m_List = new CustomCListBox;

m_List->CreateEx(extendedstyle, _T("LISTBOX"), NULL, style, CRect(50, 50, 300, 300), this, 0);

When we perform right mouse button click, program displaying “CustomCListBox::OnContextMenu message received.” as expected.

if we perform Press and hold operation on control area, program is not displaying any message.

But if we switch to comctl32.dll of older version (5.82) by removing manifesto linking from stdafx.h file then Press and hold operation is displaying “CustomCListBox::OnContextMenu message received.” Message.

//#ifdef _UNICODE

//#if defined _M_IX86

//#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")

//#elif defined _M_X64

//#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")

//#else

//#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

//#endif

//#endif

Expectation:

How can we receive press and hold operation message for populating context menu without switching to old comctl32.dll control?

OS: Windows 10 Pro


ravinalla

Continue reading...
 
Back
Top