你是否正在寻找关于translateaccelerator的内容?让我把最全的东西奉献给你:
IDocHostUIHandler::translateaccelerator快捷键不响应解决办法(即ctrl+c, ctrl+v不起作用解决办法)
标签:
本文章已收录于:
ctrlc, ctrlv不起作用的时候, 如果使用的是CHtmlView, 那么是它的一个BUG, 在资源文件中加入以下内容可以解决://///////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDC_XTPRO2 ACCELERATORS
BEGIN
“C”, ID_EDIT_COPY, VIRTKEY, CONTROL, NOINVERT
“X”, ID_EDIT_CUT, VIRTKEY, CONTROL, NOINVERT
“V”, ID_EDIT_PASTE, VIRTKEY, CONTROL, NOINVERT
END
加入有C, X, V 开头的三行, 这个比较容易. 今天讨论的主题不是CHtmlView的问题, 而是在标准Winodws API SDK编程下, 如何处理IWebBrowser2中的快捷键问题.
一. translateaccelerator为什么得不到调用?
IDocHostUIHandler::TranslateAccelerator Method is Called by MSHTML when IOleInPlaceActiveObject::TranslateAccelerator or IOleControlSite::translateaccelerator is called
IOleInPlaceActiveObject::translateaccelerator - Processes menu accelerator-key messages from the container’s message queue. This method should only be used for objects created by a DLL object application.
An object created by an EXE object application gets keystrokes from its own message pump, so the container does not get those messages.If you need to implement this method, you can do so by simply wrapping the call to the Window’s translateaccelerator function.
IOleControlSite::TranslateAccelerator – Instructs the control site to process the keystroke.This method is called by a control that can be UI-active. In such cases, a control can process all keystrokes first through IOleInPlaceActiveObject::TranslateAccelerator,
according to normal OLE Compound Document rules. Inside that method, the control can give the container certain messages to process first by calling IOleControlSite::translateaccelerator and using the return value to determine if any processing took place.
Otherwise, the control always processes the message first. If the control does not use the keystroke as an accelerator, it passes the keystroke to the container through this method.
以上Y文给我们讲得很明白, 必须要IOleInPlaceActiveObject 或者 IOleControlSite 的 TranslateAccelerator 方法得到调用, IDocHostUIHandler::TranslateAccelerator才会响应, 可见IDocHostUIHandler::translateaccelerator并不是主动响应的, 而是你的应用程序框架调用的, 调用的地方在你的消息泵处理时.
二. 如何使translateaccelerator得到调用?
在CHtmlView中, 是如下调用translateaccelerator的:
BOOL CHtmlView::PreTranslateMessage(MSG* pMsg)
{
// 省略若干处理
//…..
// check if the browser control wants to handle the message
BOOL bRet = FALSE;
if(m_pBrowserApp != NULL)
{
CComQIPtr
以上就是关于translateaccelerator的全部内容,相信你一定会非常满意,。
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shenmilingyu/article-12105-1.html
伊拉克人民或许会投你的票
不过比较灵活