MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / GetDocumentFromWindowHandle

Method GetDocumentFromWindowHandle

cpp/iedriver/BrowserFactory.cpp:459–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457
458
459bool BrowserFactory::GetDocumentFromWindowHandle(HWND window_handle,
460 IHTMLDocument2** document) {
461 LOG(TRACE) << "Entering BrowserFactory::GetDocumentFromWindowHandle";
462
463 if (window_handle != NULL && this->oleacc_instance_handle_) {
464 LRESULT result;
465
466 ::SendMessageTimeout(window_handle,
467 this->html_getobject_msg_,
468 0L,
469 0L,
470 SMTO_ABORTIFHUNG,
471 1000,
472 reinterpret_cast<PDWORD_PTR>(&result));
473
474 LPFNOBJECTFROMLRESULT object_pointer = reinterpret_cast<LPFNOBJECTFROMLRESULT>(::GetProcAddress(this->oleacc_instance_handle_, "ObjectFromLresult"));
475 if (object_pointer != NULL) {
476 HRESULT hr;
477 hr = (*object_pointer)(result,
478 IID_IHTMLDocument2,
479 0,
480 reinterpret_cast<void**>(document));
481 if (SUCCEEDED(hr)) {
482 return true;
483 } else {
484 LOGHR(WARN, hr) << "Unable to convert document object pointer to IHTMLDocument2 object via ObjectFromLresult";
485 }
486 } else {
487 LOG(WARN) << "Unable to get address of ObjectFromLresult method from library; GetProcAddress() for ObjectFromLresult returned NULL";
488 }
489 } else {
490 LOG(WARN) << "Window handle is invalid or OLEACC.DLL is not loaded properly";
491 }
492 return false;
493}
494
495bool BrowserFactory::AttachToBrowser(ProcessWindowInfo* process_window_info,
496 std::string* error_message) {

Callers 2

OnNewHtmlDialogMethod · 0.80

Calls 1

LOGClass · 0.50

Tested by

no test coverage detected