1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/webview_ie.cpp
3 // Purpose: wxMSW wxWebViewIE class implementation for web view component
4 // Author: Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if defined(__BORLANDC__)
17 #include "wx/msw/webview_ie.h"
26 #include "wx/msw/registry.h"
27 #include "wx/msw/missing.h"
29 BEGIN_EVENT_TABLE(wxWebViewIE
, wxControl
)
30 EVT_ACTIVEX(wxID_ANY
, wxWebViewIE::onActiveXEvent
)
31 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg
)
34 bool wxWebViewIE::Create(wxWindow
* parent
,
42 if (!wxControl::Create(parent
, id
, pos
, size
, style
,
43 wxDefaultValidator
, name
))
49 m_canNavigateBack
= false;
50 m_canNavigateForward
= false;
52 m_historyLoadingFromList
= false;
53 m_historyEnabled
= true;
54 m_historyPosition
= -1;
55 m_zoomType
= wxWEB_VIEW_ZOOM_TYPE_TEXT
;
57 if (::CoCreateInstance(CLSID_WebBrowser
, NULL
,
58 CLSCTX_INPROC_SERVER
, // CLSCTX_INPROC,
59 IID_IWebBrowser2
, (void**)&m_webBrowser
) != 0)
61 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
65 m_ie
.SetDispatchPtr(m_webBrowser
); // wxAutomationObject will release itself
67 m_webBrowser
->put_RegisterAsBrowser(VARIANT_TRUE
);
68 m_webBrowser
->put_RegisterAsDropTarget(VARIANT_TRUE
);
69 //m_webBrowser->put_Silent(VARIANT_FALSE);
71 m_container
= new wxActiveXContainer(this, IID_IWebBrowser2
, m_webBrowser
);
73 SetBackgroundStyle(wxBG_STYLE_PAINT
);
74 SetDoubleBuffered(true);
80 void wxWebViewIE::LoadUrl(const wxString
& url
)
82 m_ie
.CallMethod("Navigate", (BSTR
) url
.wc_str(), NULL
, NULL
, NULL
, NULL
);
85 void wxWebViewIE::SetPage(const wxString
& html
, const wxString
& baseUrl
)
87 BSTR bstr
= SysAllocString(html
.wc_str());
89 // Creates a new one-dimensional array
90 SAFEARRAY
*psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
91 if (psaStrings
!= NULL
)
95 HRESULT hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
97 param
->bstrVal
= bstr
;
98 hr
= SafeArrayUnaccessData(psaStrings
);
100 IHTMLDocument2
* document
= GetDocument();
101 document
->write(psaStrings
);
104 // SafeArrayDestroy calls SysFreeString for each BSTR
105 SafeArrayDestroy(psaStrings
);
107 //We send the events when we are done to mimic webkit
109 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
110 GetId(), baseUrl
, "", false);
111 event
.SetEventObject(this);
112 HandleWindowEvent(event
);
114 //Document complete event
115 event
.SetEventType(wxEVT_COMMAND_WEB_VIEW_LOADED
);
116 event
.SetEventObject(this);
117 HandleWindowEvent(event
);
121 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
126 wxString
wxWebViewIE::GetPageSource()
128 IHTMLDocument2
* document
= GetDocument();
129 IHTMLElement
*bodyTag
= NULL
;
130 IHTMLElement
*htmlTag
= NULL
;
132 HRESULT hr
= document
->get_body(&bodyTag
);
135 hr
= bodyTag
->get_parentElement(&htmlTag
);
139 htmlTag
->get_outerHTML(&bstr
);
140 source
= wxString(bstr
);
150 wxWebViewZoom
wxWebViewIE::GetZoom()
152 if(m_zoomType
== wxWEB_VIEW_ZOOM_TYPE_LAYOUT
)
153 return GetIEOpticalZoom();
154 else if(m_zoomType
== wxWEB_VIEW_ZOOM_TYPE_TEXT
)
155 return GetIETextZoom();
159 //Dummy return to stop compiler warnings
160 return wxWEB_VIEW_ZOOM_MEDIUM
;
164 void wxWebViewIE::SetZoom(wxWebViewZoom zoom
)
166 if(m_zoomType
== wxWEB_VIEW_ZOOM_TYPE_LAYOUT
)
167 SetIEOpticalZoom(zoom
);
168 else if(m_zoomType
== wxWEB_VIEW_ZOOM_TYPE_TEXT
)
174 void wxWebViewIE::SetIETextZoom(wxWebViewZoom level
)
176 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
177 //is 0 to 4 so the check is unnecessary, these match exactly with the
180 VariantInit (&zoomVariant
);
181 V_VT(&zoomVariant
) = VT_I4
;
182 V_I4(&zoomVariant
) = level
;
184 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
185 OLECMDEXECOPT_DONTPROMPTUSER
,
187 wxASSERT(result
== S_OK
);
190 wxWebViewZoom
wxWebViewIE::GetIETextZoom()
193 VariantInit (&zoomVariant
);
194 V_VT(&zoomVariant
) = VT_I4
;
196 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
197 OLECMDEXECOPT_DONTPROMPTUSER
,
199 wxASSERT(result
== S_OK
);
201 //We can safely cast here as we know that the range matches our enum
202 return static_cast<wxWebViewZoom
>(V_I4(&zoomVariant
));
205 void wxWebViewIE::SetIEOpticalZoom(wxWebViewZoom level
)
207 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
208 //is 10 to 1000 so the check is unnecessary
210 VariantInit (&zoomVariant
);
211 V_VT(&zoomVariant
) = VT_I4
;
213 //We make a somewhat arbitray map here, taken from values used by webkit
216 case wxWEB_VIEW_ZOOM_TINY
:
217 V_I4(&zoomVariant
) = 60;
219 case wxWEB_VIEW_ZOOM_SMALL
:
220 V_I4(&zoomVariant
) = 80;
222 case wxWEB_VIEW_ZOOM_MEDIUM
:
223 V_I4(&zoomVariant
) = 100;
225 case wxWEB_VIEW_ZOOM_LARGE
:
226 V_I4(&zoomVariant
) = 130;
228 case wxWEB_VIEW_ZOOM_LARGEST
:
229 V_I4(&zoomVariant
) = 160;
235 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
236 OLECMDEXECOPT_DODEFAULT
,
239 wxASSERT(result
== S_OK
);
242 wxWebViewZoom
wxWebViewIE::GetIEOpticalZoom()
245 VariantInit (&zoomVariant
);
246 V_VT(&zoomVariant
) = VT_I4
;
248 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
249 OLECMDEXECOPT_DODEFAULT
, NULL
,
251 wxASSERT(result
== S_OK
);
253 const int zoom
= V_I4(&zoomVariant
);
255 //We make a somewhat arbitray map here, taken from values used by webkit
258 return wxWEB_VIEW_ZOOM_TINY
;
260 else if (zoom
> 65 && zoom
<= 90)
262 return wxWEB_VIEW_ZOOM_SMALL
;
264 else if (zoom
> 90 && zoom
<= 115)
266 return wxWEB_VIEW_ZOOM_MEDIUM
;
268 else if (zoom
> 115 && zoom
<= 145)
270 return wxWEB_VIEW_ZOOM_LARGE
;
272 else /*if (zoom > 145) */ //Using else removes a compiler warning
274 return wxWEB_VIEW_ZOOM_LARGEST
;
278 void wxWebViewIE::SetZoomType(wxWebViewZoomType type
)
283 wxWebViewZoomType
wxWebViewIE::GetZoomType() const
288 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type
) const
290 //IE 6 and below only support text zoom, so check the registry to see what
291 //version we actually have
292 wxRegKey
key(wxRegKey::HKLM
, "Software\\Microsoft\\Internet Explorer");
294 key
.QueryValue("Version", value
);
296 long version
= wxAtoi(value
.Left(1));
297 if(version
<= 6 && type
== wxWEB_VIEW_ZOOM_TYPE_LAYOUT
)
303 void wxWebViewIE::Print()
305 m_webBrowser
->ExecWB(OLECMDID_PRINTPREVIEW
,
306 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
309 bool wxWebViewIE::CanGoBack()
312 return m_historyPosition
> 0;
317 bool wxWebViewIE::CanGoForward()
320 return m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1;
325 void wxWebViewIE::LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
)
328 for(unsigned int i
= 0; i
< m_historyList
.size(); i
++)
330 //We compare the actual pointers to find the correct item
331 if(m_historyList
[i
].get() == item
.get())
334 wxASSERT_MSG(pos
!= static_cast<int>(m_historyList
.size()),
335 "invalid history item");
336 m_historyLoadingFromList
= true;
337 LoadUrl(item
->GetUrl());
338 m_historyPosition
= pos
;
341 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetBackwardHistory()
343 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > backhist
;
344 //As we don't have std::copy or an iterator constructor in the wxwidgets
345 //native vector we construct it by hand
346 for(int i
= 0; i
< m_historyPosition
; i
++)
348 backhist
.push_back(m_historyList
[i
]);
353 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetForwardHistory()
355 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > forwardhist
;
356 //As we don't have std::copy or an iterator constructor in the wxwidgets
357 //native vector we construct it by hand
358 for(int i
= m_historyPosition
+ 1; i
< static_cast<int>(m_historyList
.size()); i
++)
360 forwardhist
.push_back(m_historyList
[i
]);
365 void wxWebViewIE::GoBack()
367 LoadHistoryItem(m_historyList
[m_historyPosition
- 1]);
370 void wxWebViewIE::GoForward()
372 LoadHistoryItem(m_historyList
[m_historyPosition
+ 1]);
375 void wxWebViewIE::Stop()
377 m_ie
.CallMethod("Stop");
380 void wxWebViewIE::ClearHistory()
382 m_historyList
.clear();
383 m_historyPosition
= -1;
386 void wxWebViewIE::EnableHistory(bool enable
)
388 m_historyEnabled
= enable
;
389 m_historyList
.clear();
390 m_historyPosition
= -1;
393 void wxWebViewIE::Reload(wxWebViewReloadFlags flags
)
397 V_VT(&level
) = VT_I2
;
401 case wxWEB_VIEW_RELOAD_DEFAULT
:
402 V_I2(&level
) = REFRESH_NORMAL
;
404 case wxWEB_VIEW_RELOAD_NO_CACHE
:
405 V_I2(&level
) = REFRESH_COMPLETELY
;
408 wxFAIL_MSG("Unexpected reload type");
411 m_webBrowser
->Refresh2(&level
);
414 bool wxWebViewIE::IsOfflineMode()
416 wxVariant out
= m_ie
.GetProperty("Offline");
418 wxASSERT(out
.GetType() == "bool");
420 return out
.GetBool();
423 void wxWebViewIE::SetOfflineMode(bool offline
)
425 // FIXME: the wxWidgets docs do not really document what the return
426 // parameter of PutProperty is
427 const bool success
= m_ie
.PutProperty("Offline", (offline
?
433 bool wxWebViewIE::IsBusy()
435 if (m_isBusy
) return true;
437 wxVariant out
= m_ie
.GetProperty("Busy");
439 wxASSERT(out
.GetType() == "bool");
441 return out
.GetBool();
444 wxString
wxWebViewIE::GetCurrentURL()
446 wxVariant out
= m_ie
.GetProperty("LocationURL");
448 wxASSERT(out
.GetType() == "string");
449 return out
.GetString();
452 wxString
wxWebViewIE::GetCurrentTitle()
454 IHTMLDocument2
* document
= GetDocument();
457 document
->get_nameProp(&title
);
459 return wxString(title
);
462 bool wxWebViewIE::CanCut()
464 return CanExecCommand("Cut");
467 bool wxWebViewIE::CanCopy()
469 return CanExecCommand("Copy");
471 bool wxWebViewIE::CanPaste()
473 return CanExecCommand("Paste");
476 void wxWebViewIE::Cut()
481 void wxWebViewIE::Copy()
486 void wxWebViewIE::Paste()
488 ExecCommand("Paste");
491 bool wxWebViewIE::CanUndo()
493 return CanExecCommand("Undo");
495 bool wxWebViewIE::CanRedo()
497 return CanExecCommand("Redo");
500 void wxWebViewIE::Undo()
505 void wxWebViewIE::Redo()
510 void wxWebViewIE::SetEditable(bool enable
)
512 IHTMLDocument2
* document
= GetDocument();
514 document
->put_designMode(SysAllocString(L
"On"));
516 document
->put_designMode(SysAllocString(L
"Off"));
521 bool wxWebViewIE::IsEditable()
523 IHTMLDocument2
* document
= GetDocument();
525 document
->get_designMode(&mode
);
527 if(wxString(mode
) == "On")
533 void wxWebViewIE::SelectAll()
535 ExecCommand("SelectAll");
538 bool wxWebViewIE::HasSelection()
540 IHTMLDocument2
* document
= GetDocument();
541 IHTMLSelectionObject
* selection
;
543 HRESULT hr
= document
->get_selection(&selection
);
547 selection
->get_type(&type
);
548 sel
= wxString(type
);
549 selection
->Release();
552 return sel
!= "None";
555 void wxWebViewIE::DeleteSelection()
557 ExecCommand("Delete");
560 wxString
wxWebViewIE::GetSelectedText()
562 IHTMLDocument2
* document
= GetDocument();
563 IHTMLSelectionObject
* selection
;
565 HRESULT hr
= document
->get_selection(&selection
);
569 hr
= selection
->createRange(&disrange
);
572 IHTMLTxtRange
* range
;
573 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
577 range
->get_text(&text
);
578 selected
= wxString(text
);
583 selection
->Release();
589 wxString
wxWebViewIE::GetSelectedSource()
591 IHTMLDocument2
* document
= GetDocument();
592 IHTMLSelectionObject
* selection
;
594 HRESULT hr
= document
->get_selection(&selection
);
598 hr
= selection
->createRange(&disrange
);
601 IHTMLTxtRange
* range
;
602 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
606 range
->get_htmlText(&text
);
607 selected
= wxString(text
);
612 selection
->Release();
618 void wxWebViewIE::ClearSelection()
620 IHTMLDocument2
* document
= GetDocument();
621 IHTMLSelectionObject
* selection
;
623 HRESULT hr
= document
->get_selection(&selection
);
627 selection
->Release();
632 wxString
wxWebViewIE::GetPageText()
634 IHTMLDocument2
* document
= GetDocument();
637 HRESULT hr
= document
->get_body(&body
);
641 body
->get_innerText(&out
);
642 text
= wxString(out
);
649 void wxWebViewIE::RunScript(const wxString
& javascript
)
651 IHTMLDocument2
* document
= GetDocument();
652 IHTMLWindow2
* window
;
653 wxString language
= "javascript";
654 HRESULT hr
= document
->get_parentWindow(&window
);
659 V_VT(&level
) = VT_EMPTY
;
660 window
->execScript(SysAllocString(javascript
), SysAllocString(language
), &level
);
665 bool wxWebViewIE::CanExecCommand(wxString command
)
667 IHTMLDocument2
* document
= GetDocument();
668 VARIANT_BOOL enabled
;
670 document
->queryCommandEnabled(SysAllocString(command
.wc_str()), &enabled
);
673 return (enabled
== VARIANT_TRUE
);
676 void wxWebViewIE::ExecCommand(wxString command
)
678 IHTMLDocument2
* document
= GetDocument();
679 document
->execCommand(SysAllocString(command
.wc_str()), VARIANT_FALSE
, VARIANT(), NULL
);
683 IHTMLDocument2
* wxWebViewIE::GetDocument()
685 wxVariant variant
= m_ie
.GetProperty("Document");
686 IHTMLDocument2
* document
= (IHTMLDocument2
*)variant
.GetVoidPtr();
693 void wxWebViewIE::onActiveXEvent(wxActiveXEvent
& evt
)
695 if (m_webBrowser
== NULL
) return;
697 switch (evt
.GetDispatchId())
699 case DISPID_BEFORENAVIGATE2
:
703 wxString url
= evt
[1].GetString();
704 wxString target
= evt
[3].GetString();
706 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING
,
707 GetId(), url
, target
, true);
708 event
.SetEventObject(this);
709 HandleWindowEvent(event
);
711 if (event
.IsVetoed())
713 wxActiveXEventNativeMSW
* nativeParams
=
714 evt
.GetNativeParameters();
715 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[0]) = VARIANT_TRUE
;
718 // at this point, either the navigation event has been cancelled
719 // and we're not busy, either it was accepted and IWebBrowser2's
720 // Busy property will be true; so we don't need our override
727 case DISPID_NAVIGATECOMPLETE2
:
729 wxString url
= evt
[1].GetString();
730 // TODO: set target parameter if possible
731 wxString target
= wxEmptyString
;
732 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
733 GetId(), url
, target
, false);
734 event
.SetEventObject(this);
735 HandleWindowEvent(event
);
739 case DISPID_PROGRESSCHANGE
:
745 case DISPID_DOCUMENTCOMPLETE
:
747 //Only send a complete even if we are actually finished, this brings
748 //the event in to line with webkit
750 m_webBrowser
->get_ReadyState( &rs
);
751 if(rs
!= READYSTATE_COMPLETE
)
754 wxString url
= evt
[1].GetString();
756 //As we are complete we also add to the history list, but not if the
757 //page is not the main page, ie it is a subframe
758 if(m_historyEnabled
&& !m_historyLoadingFromList
&& url
== GetCurrentURL())
760 //If we are not at the end of the list, then erase everything
761 //between us and the end before adding the new page
762 if(m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1)
764 m_historyList
.erase(m_historyList
.begin() + m_historyPosition
+ 1,
765 m_historyList
.end());
767 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(url
, GetCurrentTitle()));
768 m_historyList
.push_back(item
);
771 //Reset as we are done now
772 m_historyLoadingFromList
= false;
773 // TODO: set target parameter if possible
774 wxString target
= wxEmptyString
;
775 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_LOADED
, GetId(),
777 event
.SetEventObject(this);
778 HandleWindowEvent(event
);
782 case DISPID_STATUSTEXTCHANGE
:
787 case DISPID_TITLECHANGE
:
792 case DISPID_NAVIGATEERROR
:
794 wxWebNavigationError errorType
= wxWEB_NAV_ERR_OTHER
;
795 wxString errorCode
= "?";
796 switch (evt
[3].GetLong())
798 case INET_E_INVALID_URL
: // (0x800C0002L or -2146697214)
799 errorCode
= "INET_E_INVALID_URL";
800 errorType
= wxWEB_NAV_ERR_REQUEST
;
802 case INET_E_NO_SESSION
: // (0x800C0003L or -2146697213)
803 errorCode
= "INET_E_NO_SESSION";
804 errorType
= wxWEB_NAV_ERR_CONNECTION
;
806 case INET_E_CANNOT_CONNECT
: // (0x800C0004L or -2146697212)
807 errorCode
= "INET_E_CANNOT_CONNECT";
808 errorType
= wxWEB_NAV_ERR_CONNECTION
;
810 case INET_E_RESOURCE_NOT_FOUND
: // (0x800C0005L or -2146697211)
811 errorCode
= "INET_E_RESOURCE_NOT_FOUND";
812 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
814 case INET_E_OBJECT_NOT_FOUND
: // (0x800C0006L or -2146697210)
815 errorCode
= "INET_E_OBJECT_NOT_FOUND";
816 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
818 case INET_E_DATA_NOT_AVAILABLE
: // (0x800C0007L or -2146697209)
819 errorCode
= "INET_E_DATA_NOT_AVAILABLE";
820 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
822 case INET_E_DOWNLOAD_FAILURE
: // (0x800C0008L or -2146697208)
823 errorCode
= "INET_E_DOWNLOAD_FAILURE";
824 errorType
= wxWEB_NAV_ERR_CONNECTION
;
826 case INET_E_AUTHENTICATION_REQUIRED
: // (0x800C0009L or -2146697207)
827 errorCode
= "INET_E_AUTHENTICATION_REQUIRED";
828 errorType
= wxWEB_NAV_ERR_AUTH
;
830 case INET_E_NO_VALID_MEDIA
: // (0x800C000AL or -2146697206)
831 errorCode
= "INET_E_NO_VALID_MEDIA";
832 errorType
= wxWEB_NAV_ERR_REQUEST
;
834 case INET_E_CONNECTION_TIMEOUT
: // (0x800C000BL or -2146697205)
835 errorCode
= "INET_E_CONNECTION_TIMEOUT";
836 errorType
= wxWEB_NAV_ERR_CONNECTION
;
838 case INET_E_INVALID_REQUEST
: // (0x800C000CL or -2146697204)
839 errorCode
= "INET_E_INVALID_REQUEST";
840 errorType
= wxWEB_NAV_ERR_REQUEST
;
842 case INET_E_UNKNOWN_PROTOCOL
: // (0x800C000DL or -2146697203)
843 errorCode
= "INET_E_UNKNOWN_PROTOCOL";
844 errorType
= wxWEB_NAV_ERR_REQUEST
;
846 case INET_E_SECURITY_PROBLEM
: // (0x800C000EL or -2146697202)
847 errorCode
= "INET_E_SECURITY_PROBLEM";
848 errorType
= wxWEB_NAV_ERR_SECURITY
;
850 case INET_E_CANNOT_LOAD_DATA
: // (0x800C000FL or -2146697201)
851 errorCode
= "INET_E_CANNOT_LOAD_DATA";
852 errorType
= wxWEB_NAV_ERR_OTHER
;
854 case INET_E_CANNOT_INSTANTIATE_OBJECT
:
855 // CoCreateInstance will return an error code if this happens,
856 // we'll handle this above.
859 case INET_E_REDIRECT_FAILED
: // (0x800C0014L or -2146697196)
860 errorCode
= "INET_E_REDIRECT_FAILED";
861 errorType
= wxWEB_NAV_ERR_OTHER
;
863 case INET_E_REDIRECT_TO_DIR
: // (0x800C0015L or -2146697195)
864 errorCode
= "INET_E_REDIRECT_TO_DIR";
865 errorType
= wxWEB_NAV_ERR_REQUEST
;
867 case INET_E_CANNOT_LOCK_REQUEST
: // (0x800C0016L or -2146697194)
868 errorCode
= "INET_E_CANNOT_LOCK_REQUEST";
869 errorType
= wxWEB_NAV_ERR_OTHER
;
871 case INET_E_USE_EXTEND_BINDING
: // (0x800C0017L or -2146697193)
872 errorCode
= "INET_E_USE_EXTEND_BINDING";
873 errorType
= wxWEB_NAV_ERR_OTHER
;
875 case INET_E_TERMINATED_BIND
: // (0x800C0018L or -2146697192)
876 errorCode
= "INET_E_TERMINATED_BIND";
877 errorType
= wxWEB_NAV_ERR_OTHER
;
879 case INET_E_INVALID_CERTIFICATE
: // (0x800C0019L or -2146697191)
880 errorCode
= "INET_E_INVALID_CERTIFICATE";
881 errorType
= wxWEB_NAV_ERR_CERTIFICATE
;
883 case INET_E_CODE_DOWNLOAD_DECLINED
: // (0x800C0100L or -2146696960)
884 errorCode
= "INET_E_CODE_DOWNLOAD_DECLINED";
885 errorType
= wxWEB_NAV_ERR_USER_CANCELLED
;
887 case INET_E_RESULT_DISPATCHED
: // (0x800C0200L or -2146696704)
888 // cancel request cancelled...
889 errorCode
= "INET_E_RESULT_DISPATCHED";
890 errorType
= wxWEB_NAV_ERR_OTHER
;
892 case INET_E_CANNOT_REPLACE_SFP_FILE
: // (0x800C0300L or -2146696448)
893 errorCode
= "INET_E_CANNOT_REPLACE_SFP_FILE";
894 errorType
= wxWEB_NAV_ERR_SECURITY
;
896 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY
:
897 errorCode
= "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
898 errorType
= wxWEB_NAV_ERR_SECURITY
;
900 case INET_E_CODE_INSTALL_SUPPRESSED
:
901 errorCode
= "INET_E_CODE_INSTALL_SUPPRESSED";
902 errorType
= wxWEB_NAV_ERR_SECURITY
;
906 wxString url
= evt
[1].GetString();
907 wxString target
= evt
[2].GetString();
908 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_ERROR
, GetId(),
910 event
.SetEventObject(this);
911 event
.SetInt(errorType
);
912 event
.SetString(errorCode
);
913 HandleWindowEvent(event
);
917 case DISPID_COMMANDSTATECHANGE
:
919 long commandId
= evt
[0].GetLong();
920 bool enable
= evt
[1].GetBool();
921 if (commandId
== CSC_NAVIGATEBACK
)
923 m_canNavigateBack
= enable
;
925 else if (commandId
== CSC_NAVIGATEFORWARD
)
927 m_canNavigateForward
= enable
;
931 case DISPID_NEWWINDOW3
:
933 wxString url
= evt
[4].GetString();
935 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW
,
936 GetId(), url
, wxEmptyString
, true);
937 event
.SetEventObject(this);
938 HandleWindowEvent(event
);
940 //If we veto the event then we cancel the new window
941 if (event
.IsVetoed())
943 wxActiveXEventNativeMSW
* nativeParams
= evt
.GetNativeParameters();
944 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[3]) = VARIANT_TRUE
;