在 Windows Mobile 中使用 PostMessage 模拟菜单选择
我正在编写一个例程,为我的 Windows Mobile 5 应用程序(使用 C++/MFC 编写)中的任何菜单项提供用户可定义的键盘快捷键。 为此,我获取所有可用的菜单命令 ID,并使用 CWnd::PostMessage(WM_COMMAND,MyMenuID) 将其发布到应用程序。 我在其他地方使用此技术对线程间通信产生了良好的效果,但对于菜单命令 ID 却没有。 任何想法为什么这不起作用。 该应用程序是文档视图,我尝试发布到 CMainFrame 和 CView 派生窗口。 我可以写一个糟糕透顶的 switch 语句,但我觉得发布一条消息应该可行。
编辑:好的,我已经尝试了很多方法,包括来自
I'm writing a routine to provide user definable keyboard short-cuts for any menu item in my Windows Mobile 5 application, which is in C++/MFC. To do this I am getting all of the available menu command IDs, and using the CWnd::PostMessage(WM_COMMAND,MyMenuID) to post it to the application. I use this technique to good effect elsewhere for inter-thread comms, but not with menu command IDs. Any ideas why this doesn't work. The app is document view, and I have tried posting to the CMainFrame and CView derived windows. I could write a god awful switch statement but I feel posting a message should work.
Edit: Ok, i've tried a number of things, including suggestions from this post, to no avail. Big ugly switch statement it is for now, I'll update again if i find anything better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一原因是消息发送到了错误的窗口。 不要忘记,并非所有菜单命令总是由特定窗口处理。 一些菜单命令(例如“剪切”)通常由视图窗口处理。 其他由框架窗口处理,有些可能由应用程序对象处理。
希望这可以帮助。
The only reason I can think of is the message is going to the wrong window. Don't forget that not all menu commands are always processed by a particular window. Some menu commands like Cut are usually processed by a view window. Others are processed by frame windows and some possibly by the application object.
Hope this helps.