How to programmatically activate the menu in Windows mobile

荒凉一梦 提交于 2019-12-12 23:17:13

问题


In most versions of windows, you can get to the menu by pressing the F10 key, thus avoiding having to use the mouse. This behaviour does not appear to be present in Windows Mobile 5.0, but is desirable as the device I am using will be more keyboard than touch screen driven.

Is there a way of programmatically activating and using the menu on Windows Mobile 5.0, under C++ using either MFC or Windows API calls. I have tried setting the focus of the CFrameWnd and CCeCommandBar classes to no avail.


回答1:


After a number of attempts, the following appears to work;

void CMyFrame::OnFocusMenu()
{
  PostMessage(WM_SYSCOMMAND,SC_KEYMENU,0);
}

FWIW, none of the following did, where m_wndCommandBar is the CCeCommandBar toolbar containing the menu;

::SetActiveWindow(m_wndCommandBar.m_hWnd);
m_wndCommandBar.PostMessage(WM_ACTIVATE,WA_ACTIVE,0);
m_wndCommandBar.PostMessage(WM_LBUTTONDOWN,0,0);
m_wndCommandBar.PostMessage(WM_LBUTTONUP,0,0);
m_wndCommandBar.OnActivate(WA_ACTIVE, NULL, FALSE);
m_wndCommandBar.SetFocus();



回答2:


If by menu, you mean the soft keys, note that they are bound to F1 and F2 respectively.



来源:https://stackoverflow.com/questions/256719/how-to-programmatically-activate-the-menu-in-windows-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!