LRESULT CWebBrowserUI::TranslateAccelerator( MSG *pMsg ) { if(pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) return S_FALSE; if( m_pWebBrowser2 == NULL ) return E_NOTIMPL; // 当前Web窗口不是焦点,不处理加速键 BOOL bIsChild = FALSE; HWND hTempWnd = NULL; HWND hWndFocus = ::GetFocus(); hTempWnd = hWndFocus; while(hTempWnd != NULL) { if(hTempWnd == m_hwndHost) { bIsChild = TRUE; break; } hTempWnd = ::GetParent(hTempWnd); } if(!bIsChild) return S_FALSE; IOleInPlaceActiveObject *pObj; if (FAILED(m_pWebBrowser2->QueryInterface(IID_IOleInPlaceActiveObject, (LPVOID *)&pObj))) return S_FALSE; HRESULT hResult = pObj->TranslateAccelerator(pMsg); pObj->Release(); return hResult; }
void CIEBrowserEngine::RunMessageLoop(CMainWindow& mainWnd) { MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { if (RHODESAPP().getExtManager().onWndMsg(msg) ) continue; IDispatch* pDisp; SendMessage(m_hwndTabHTML, DTM_BROWSERDISPATCH, 0, (LPARAM) &pDisp); // New HTMLVIEW message if (pDisp != NULL) { // If the Key is back we do not want to translate it causing the browser // to navigate back. if ( ((msg.message != WM_KEYUP) && (msg.message != WM_KEYDOWN)) || (msg.wParam != VK_BACK) ) { IOleInPlaceActiveObject* pInPlaceObject; pDisp->QueryInterface( IID_IOleInPlaceActiveObject, (void**)&pInPlaceObject ); HRESULT handleKey = pInPlaceObject->TranslateAccelerator(&msg); } } if (!mainWnd.TranslateAccelerator(&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message == WM_PAINT) RHODESAPP().getExtManager().onHTMLWndMsg(msg); } }
LRESULT DuiLib::CWebBrowserUI::TranslateAccelerator( MSG *pMsg ) { if( m_pWebBrowser2 != NULL ) { IOleInPlaceActiveObject *pObj; if (FAILED(m_pWebBrowser2->QueryInterface(IID_IOleInPlaceActiveObject, (LPVOID *)&pObj))) return S_FALSE; return pObj->TranslateAccelerator(pMsg); } return E_NOTIMPL; }
void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) { IOleInPlaceActiveObject* pIOIPAO; if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pIOIPAO))) { MSG msg; msg.message = uMsg; msg.wParam = wParam; msg.lParam = lParam; pIOIPAO->TranslateAccelerator(&msg); pIOIPAO->Release(); } }
HRESULT AxContainer::OnTranslateAccelerator( MSG &msg ) { if (m_pOleObject == NULL) return S_FALSE; IOleInPlaceActiveObject *pObj; if (FAILED(m_pOleObject->QueryInterface(IID_IOleInPlaceActiveObject, (LPVOID *)&pObj))) return S_FALSE; HRESULT hResult = pObj->TranslateAccelerator(&msg); pObj->Release(); return hResult; }
STDMETHOD(SetActiveObject)(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR /*pszObjName*/) { if( pActiveObject != NULL ) pActiveObject->AddRef(); if( m_pActiveObject != NULL ) m_pActiveObject->Release(); m_pActiveObject = pActiveObject; return S_OK; }
// @pymethod |PyIDocHostUIHandler|ShowUI|Description of ShowUI. PyObject *PyIDocHostUIHandler::ShowUI(PyObject *self, PyObject *args) { IDocHostUIHandler *pIDHUIH = GetI(self); if ( pIDHUIH == NULL ) return NULL; // @pyparm int|dwID||Description for dwID // @pyparm <o PyIOleInPlaceActiveObject>|pActiveObject||Description for pActiveObject // @pyparm <o PyIOleCommandTarget>|pCommandTarget||Description for pCommandTarget // @pyparm <o PyIOleInPlaceFrame>|pFrame||Description for pFrame // @pyparm <o PyIOleInPlaceUIWindow>|pDoc||Description for pDoc PyObject *obpActiveObject; PyObject *obpCommandTarget; PyObject *obpFrame; PyObject *obpDoc; DWORD dwID; if ( !PyArg_ParseTuple(args, "lOOOO:ShowUI", &dwID, &obpActiveObject, &obpCommandTarget, &obpFrame, &obpDoc) ) return NULL; IOleInPlaceActiveObject * pActiveObject; IOleCommandTarget * pCommandTarget; IOleInPlaceFrame * pFrame; IOleInPlaceUIWindow * pDoc; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpActiveObject, IID_IOleInPlaceActiveObject, (void **)&pActiveObject, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpCommandTarget, IID_IOleCommandTarget, (void **)&pCommandTarget, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpFrame, IID_IOleInPlaceFrame, (void **)&pFrame, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpDoc, IID_IOleInPlaceUIWindow, (void **)&pDoc, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDHUIH->ShowUI( dwID, pActiveObject, pCommandTarget, pFrame, pDoc ); if (pActiveObject) pActiveObject->Release(); if (pCommandTarget) pCommandTarget->Release(); if (pFrame) pFrame->Release(); if (pDoc) pDoc->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler ); return PyInt_FromLong(hr); }
void CIEBrowserEngine::RunMessageLoop(CMainWindow& mainWnd) { MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { // Used for Zoom-In Or Zoom-Out, if the return value is true then // the message will be pushed further so that the remaining action // on that function key can be processed. // For Ex: After Zoom In or Zoom Out, the same key may be used by JavaScript // or KeyCapture Module to perform other task from the html page. if ( !RHODESAPP().getExtManager().onZoomTextWndMsg(msg) ) continue; if (RHODESAPP().getExtManager().onWndMsg(msg) ) continue; IDispatch* pDisp; SendMessage(m_hwndTabHTML, DTM_BROWSERDISPATCH, 0, (LPARAM) &pDisp); // New HTMLVIEW message if (pDisp != NULL) { // If the Key is back we do not want to translate it causing the browser // to navigate back. if ( ((msg.message != WM_KEYUP) && (msg.message != WM_KEYDOWN)) || (msg.wParam != VK_BACK) ) { IOleInPlaceActiveObject* pInPlaceObject; pDisp->QueryInterface( IID_IOleInPlaceActiveObject, (void**)&pInPlaceObject ); HRESULT handleKey = pInPlaceObject->TranslateAccelerator(&msg); } } if (!mainWnd.TranslateAccelerator(&msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message == WM_PAINT) RHODESAPP().getExtManager().onHTMLWndMsg(msg); } }
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { HANDLE hSharedBuffer = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, MAX_URL, __SHAREDMEM_NAME__); if (hSharedBuffer != NULL) { _SharedBufer = (char*)::MapViewOfFile(hSharedBuffer, FILE_MAP_ALL_ACCESS, 0, 0, MAX_URL); } if (::GetLastError() == ERROR_ALREADY_EXISTS) { hSharedBuffer = OpenFileMapping( FILE_MAP_ALL_ACCESS, TRUE, __SHAREDMEM_NAME__); if (hSharedBuffer != NULL) { _SharedBufer = (char*)::MapViewOfFile(hSharedBuffer, FILE_MAP_ALL_ACCESS, 0, 0, MAX_URL); memset(_SharedBufer, 0, MAX_URL); strncpy(_SharedBufer, lpCmdLine, MAX_URL-1); _hAfxBrwsEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, __EVENT_NAME__); if (_hAfxBrwsEvent != NULL) { ::SetEvent(_hAfxBrwsEvent); ::CloseHandle(_hAfxBrwsEvent); } ::UnmapViewOfFile(_SharedBufer); ::CloseHandle(hSharedBuffer); } return -1; } _hAfxWnd = ::FindWindow(_T("TAfxWForm"), NULL); if (_hAfxWnd == INVALID_HANDLE_VALUE) { _hAfxWnd = ::FindWindow(_T("TAfxForm"), NULL); if (_hAfxWnd == INVALID_HANDLE_VALUE) { ::UnmapViewOfFile(_SharedBufer); ::CloseHandle(hSharedBuffer); return -1; } } char ini_path[MAX_PATH]; GetModuleFileName(NULL, ini_path, sizeof(ini_path)); int len = strlen(ini_path); if (len+2 >= MAX_PATH) { return -1; } ini_path[len-3] = 'i'; ini_path[len-2] = 'n'; ini_path[len-1] = 'i'; _stay_mode = ::GetPrivateProfileInt("Config", "stay", 1, ini_path); _hAfxBrwsEvent = ::CreateEvent(NULL, FALSE, FALSE, __EVENT_NAME__); RECT rect; ::GetWindowRect(_hAfxWnd, &rect); IEComponent ie(_hAfxWnd, hInstance, 0, 0, rect.right - rect.left, rect.bottom - rect.top); ie.LoadPage(lpCmdLine); _hBroWnd = ie.GetWndIE(); SetFocusOtherProcess(ie.GetWndIE()); IOleInPlaceActiveObject* actObj = ie.GetActObj(); _ie = &ie; DWORD thId1; _hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Thread1, NULL, 0, &thId1); MSG msg; while (GetMessage (&msg, NULL, 0, 0)) { if (actObj->TranslateAccelerator(&msg)) { TranslateMessage (&msg); DispatchMessage (&msg); } } if (_fullscreen) { ::MoveWindow(_hAfxWnd, _rect_pre_fullscreen.left, _rect_pre_fullscreen.top, _rect_pre_fullscreen.right - _rect_pre_fullscreen.left, _rect_pre_fullscreen.bottom - _rect_pre_fullscreen.top, TRUE); } _thread_exit = TRUE; ::WaitForSingleObject(_hThread, INFINITE); ::CloseHandle(_hAfxBrwsEvent); ::UnmapViewOfFile(_SharedBufer); ::CloseHandle(hSharedBuffer); ::CloseHandle(_hThread); SetFocusOtherProcess(_hAfxWnd); return msg.wParam; };
LRESULT CALLBACK mHpWebClient::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SIZE: { mHpWebClient* win = reinterpret_cast<mHpWebClient*> (::GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (win) { win->Resize(LOWORD(lParam), HIWORD(lParam)); } return 0; } case WM_CREATE: { return 0; } case WM_KEYDOWN: { TraceFunc("WM_KEYDOWN in mHpWebClient"); Trace2("wParam: ", wParam); if (wParam == VK_TAB) { /* The following code is necessary to enable 'tabulator navigating' in forms. See also http://www.microsoft.com/0499/faq/faq0499.asp and the SendMessage part in the MessageLoop */ IOleInPlaceActiveObject* ipao; IWebBrowser2 *webBrowser2; mHpWebClient* win = reinterpret_cast<mHpWebClient*> (::GetWindowLongPtr(hwnd, GWLP_USERDATA)); if (win) { if (!win->browserObject_->QueryInterface(IID_IWebBrowser2, (void**)&webBrowser2)) { webBrowser2->QueryInterface(IID_IOleInPlaceActiveObject, reinterpret_cast<void**>(&ipao)); if (ipao) { MSG m; m.message=WM_KEYDOWN; m.wParam = wParam; m.lParam = lParam; m.hwnd = hwnd; ipao->TranslateAccelerator(&m); } else { ::MessageBox(0, "Failed to retrieve IOleInPlaceActiveObject in WM_KEYDOWN", 0, 0); } } return 0; } else { ::MessageBox(0, "Failed to retrieve webBrowser2 in WM_KEYDOWN", 0, 0); } return -1; } break; } case WM_APP: { TraceFunc("WM_APP called"); mHpWebClient* win = reinterpret_cast<mHpWebClient* >(::GetWindowLongPtr(hwnd, GWLP_USERDATA)); std::string* path_with_params = reinterpret_cast<std::string*>(wParam); std::string path; std::map<std::string,std::string> params; Trace(std::string("path_with_params: ") + *path_with_params); SplitGetReq(*path_with_params, path, params); Trace(std::string("path: ") + path); std::string out_html; win->AppLink(path, out_html, params); win->HTML(out_html); // url is allocated in DOCHostHandler.cpp Trace("going to delete url"); //delete url; delete path_with_params; // param_map is allocated in DOCHostHandler.cpp Trace("going to delete param_map"); //delete param_map; Trace("param_map deleted"); return 0; } } return(DefWindowProc(hwnd, uMsg, wParam, lParam)); }