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"
27 // Various definitions are missing from mingw
29 typedef enum CommandStateChangeConstants
{
30 CSC_UPDATECOMMANDS
= (int) 0xFFFFFFFF,
31 CSC_NAVIGATEFORWARD
= 0x1,
32 CSC_NAVIGATEBACK
= 0x2
33 } CommandStateChangeConstants
;
35 #define DISPID_COMMANDSTATECHANGE 105
36 #define DISPID_NAVIGATECOMPLETE2 252
37 #define DISPID_NAVIGATEERROR 271
38 #define DISPID_NEWWINDOW3 273
39 #define OLECMDID_OPTICAL_ZOOM 63
40 #define INET_E_ERROR_FIRST 0x800C0002L
41 #define INET_E_INVALID_URL 0x800C0002L
42 #define INET_E_NO_SESSION 0x800C0003L
43 #define INET_E_CANNOT_CONNECT 0x800C0004L
44 #define INET_E_RESOURCE_NOT_FOUND 0x800C0005L
45 #define INET_E_OBJECT_NOT_FOUND 0x800C0006L
46 #define INET_E_DATA_NOT_AVAILABLE 0x800C0007L
47 #define INET_E_DOWNLOAD_FAILURE 0x800C0008L
48 #define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L
49 #define INET_E_NO_VALID_MEDIA 0x800C000AL
50 #define INET_E_CONNECTION_TIMEOUT 0x800C000BL
51 #define INET_E_INVALID_REQUEST 0x800C000CL
52 #define INET_E_UNKNOWN_PROTOCOL 0x800C000DL
53 #define INET_E_SECURITY_PROBLEM 0x800C000EL
54 #define INET_E_CANNOT_LOAD_DATA 0x800C000FL
55 #define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L
56 #define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L
57 #define INET_E_REDIRECT_FAILED 0x800C0014L
58 #define INET_E_REDIRECT_TO_DIR 0x800C0015L
59 #define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L
60 #define INET_E_USE_EXTEND_BINDING 0x800C0017L
61 #define INET_E_TERMINATED_BIND 0x800C0018L
62 #define INET_E_INVALID_CERTIFICATE 0x800C0019L
63 #define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L
64 #define INET_E_RESULT_DISPATCHED 0x800C0200L
65 #define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L
66 #define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L
67 #define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L
69 #define REFRESH_NORMAL 0
70 #define REFRESH_COMPLETELY 3
73 BEGIN_EVENT_TABLE(wxWebViewIE
, wxControl
)
74 EVT_ACTIVEX(wxID_ANY
, wxWebViewIE::onActiveXEvent
)
75 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg
)
78 bool wxWebViewIE::Create(wxWindow
* parent
,
86 if (!wxControl::Create(parent
, id
, pos
, size
, style
,
87 wxDefaultValidator
, name
))
93 m_canNavigateBack
= false;
94 m_canNavigateForward
= false;
96 m_historyLoadingFromList
= false;
97 m_historyEnabled
= true;
98 m_historyPosition
= -1;
100 if (::CoCreateInstance(CLSID_WebBrowser
, NULL
,
101 CLSCTX_INPROC_SERVER
, // CLSCTX_INPROC,
102 IID_IWebBrowser2
, (void**)&m_webBrowser
) != 0)
104 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
108 m_ie
.SetDispatchPtr(m_webBrowser
); // wxAutomationObject will release itself
110 m_webBrowser
->put_RegisterAsBrowser(VARIANT_TRUE
);
111 m_webBrowser
->put_RegisterAsDropTarget(VARIANT_TRUE
);
112 //m_webBrowser->put_Silent(VARIANT_FALSE);
114 m_container
= new wxActiveXContainer(this, IID_IWebBrowser2
, m_webBrowser
);
116 SetBackgroundStyle(wxBG_STYLE_PAINT
);
117 SetDoubleBuffered(true);
123 void wxWebViewIE::LoadUrl(const wxString
& url
)
125 wxVariant out
= m_ie
.CallMethod("Navigate", (BSTR
) url
.wc_str(),
126 NULL
, NULL
, NULL
, NULL
);
128 // FIXME: why is out value null??
129 //(HRESULT)(out.GetLong()) == S_OK;
132 void wxWebViewIE::SetPage(const wxString
& html
, const wxString
&)
134 LoadUrl("about:blank");
136 // Let the wx events generated for navigation events be processed, so
137 // that the underlying IE component completes its Document object.
138 // FIXME: calling wxYield is not elegant nor very reliable probably
141 // TODO: consider the "baseUrl" parameter if possible
142 // TODO: consider encoding
143 BSTR bstr
= SysAllocString(html
.wc_str());
145 // Creates a new one-dimensional array
146 SAFEARRAY
*psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
147 if (psaStrings
!= NULL
)
150 HRESULT hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
152 param
->bstrVal
= bstr
;
154 hr
= SafeArrayUnaccessData(psaStrings
);
155 IHTMLDocument2
* document
= GetDocument();
156 document
->write(psaStrings
);
158 // SafeArrayDestroy calls SysFreeString for each BSTR
159 SafeArrayDestroy(psaStrings
);
163 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
168 wxString
wxWebViewIE::GetPageSource()
170 IHTMLDocument2
* document
= GetDocument();
171 IHTMLElement
*bodyTag
= NULL
;
172 IHTMLElement
*htmlTag
= NULL
;
173 document
->get_body(&bodyTag
);
174 wxASSERT(bodyTag
!= NULL
);
177 bodyTag
->get_parentElement(&htmlTag
);
178 wxASSERT(htmlTag
!= NULL
);
181 htmlTag
->get_outerHTML(&bstr
);
186 //wxMessageBox(wxString(bstr));
188 // TODO: check encoding
189 return wxString(bstr
);
192 // FIXME? retrieve OLECMDID_GETZOOMRANGE instead of hardcoding range 0-4
193 wxWebViewZoom
wxWebViewIE::GetZoom()
195 const int zoom
= GetIETextZoom();
200 return wxWEB_VIEW_ZOOM_TINY
;
203 return wxWEB_VIEW_ZOOM_SMALL
;
206 return wxWEB_VIEW_ZOOM_MEDIUM
;
209 return wxWEB_VIEW_ZOOM_LARGE
;
212 return wxWEB_VIEW_ZOOM_LARGEST
;
216 return wxWEB_VIEW_ZOOM_MEDIUM
;
219 void wxWebViewIE::SetZoom(wxWebViewZoom zoom
)
221 // I know I could cast from enum to int since wxWebViewZoom happens to
222 // match with IE's zoom levels, but I don't like doing that, what if enum
226 case wxWEB_VIEW_ZOOM_TINY
:
229 case wxWEB_VIEW_ZOOM_SMALL
:
232 case wxWEB_VIEW_ZOOM_MEDIUM
:
235 case wxWEB_VIEW_ZOOM_LARGE
:
238 case wxWEB_VIEW_ZOOM_LARGEST
:
246 void wxWebViewIE::SetIETextZoom(int level
)
249 VariantInit (&zoomVariant
);
250 V_VT(&zoomVariant
) = VT_I4
;
251 V_I4(&zoomVariant
) = level
;
253 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
254 OLECMDEXECOPT_DONTPROMPTUSER
,
256 wxASSERT (result
== S_OK
);
258 VariantClear (&zoomVariant
);
261 int wxWebViewIE::GetIETextZoom()
264 VariantInit (&zoomVariant
);
265 V_VT(&zoomVariant
) = VT_I4
;
266 V_I4(&zoomVariant
) = 4;
268 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
269 OLECMDEXECOPT_DONTPROMPTUSER
,
271 wxASSERT (result
== S_OK
);
273 int zoom
= V_I4(&zoomVariant
);
274 // wxMessageBox(wxString::Format("Zoom : %i", zoom));
275 VariantClear (&zoomVariant
);
280 void wxWebViewIE::SetIEOpticalZoom(float zoom
)
282 // TODO: add support for optical zoom (IE7+ only)
284 // TODO: get range from OLECMDID_OPTICAL_GETZOOMRANGE instead of hardcoding?
285 wxASSERT(zoom
>= 10.0f
);
286 wxASSERT(zoom
<= 1000.0f
);
289 VariantInit (&zoomVariant
);
290 V_VT(&zoomVariant
) = VT_I4
;
291 V_I4(&zoomVariant
) = (zoom
* 100.0f
);
293 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
294 OLECMDEXECOPT_DODEFAULT
,
297 wxASSERT (result
== S_OK
);
300 float wxWebViewIE::GetIEOpticalZoom()
302 // TODO: add support for optical zoom (IE7+ only)
305 VariantInit (&zoomVariant
);
306 V_VT(&zoomVariant
) = VT_I4
;
307 V_I4(&zoomVariant
) = -1;
309 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
310 OLECMDEXECOPT_DODEFAULT
, NULL
,
312 wxASSERT (result
== S_OK
);
314 const int zoom
= V_I4(&zoomVariant
);
315 VariantClear (&zoomVariant
);
317 return zoom
/ 100.0f
;
320 void wxWebViewIE::SetZoomType(wxWebViewZoomType
)
322 // TODO: add support for optical zoom (IE7+ only)
326 wxWebViewZoomType
wxWebViewIE::GetZoomType() const
328 // TODO: add support for optical zoom (IE7+ only)
329 return wxWEB_VIEW_ZOOM_TYPE_TEXT
;
332 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType
) const
334 // both are supported
335 // TODO: IE6 only supports text zoom, check if it's IE6 first
339 void wxWebViewIE::Print()
341 m_webBrowser
->ExecWB(OLECMDID_PRINTPREVIEW
,
342 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
345 bool wxWebViewIE::CanGoBack()
348 return m_historyPosition
> 0;
353 bool wxWebViewIE::CanGoForward()
356 return m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1;
361 void wxWebViewIE::LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
)
364 for(unsigned int i
= 0; i
< m_historyList
.size(); i
++)
366 //We compare the actual pointers to find the correct item
367 if(m_historyList
[i
].get() == item
.get())
370 wxASSERT_MSG(pos
!= static_cast<int>(m_historyList
.size()),
371 "invalid history item");
372 m_historyLoadingFromList
= true;
373 LoadUrl(item
->GetUrl());
374 m_historyPosition
= pos
;
377 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetBackwardHistory()
379 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > backhist
;
380 //As we don't have std::copy or an iterator constructor in the wxwidgets
381 //native vector we construct it by hand
382 for(int i
= 0; i
< m_historyPosition
; i
++)
384 backhist
.push_back(m_historyList
[i
]);
389 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetForwardHistory()
391 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > forwardhist
;
392 //As we don't have std::copy or an iterator constructor in the wxwidgets
393 //native vector we construct it by hand
394 for(int i
= m_historyPosition
+ 1; i
< static_cast<int>(m_historyList
.size()); i
++)
396 forwardhist
.push_back(m_historyList
[i
]);
401 void wxWebViewIE::GoBack()
403 LoadHistoryItem(m_historyList
[m_historyPosition
- 1]);
406 void wxWebViewIE::GoForward()
408 LoadHistoryItem(m_historyList
[m_historyPosition
+ 1]);
411 void wxWebViewIE::Stop()
413 wxVariant out
= m_ie
.CallMethod("Stop");
415 // FIXME: why is out value null??
416 //return (HRESULT)(out.GetLong()) == S_OK;
419 void wxWebViewIE::ClearHistory()
421 m_historyList
.clear();
422 m_historyPosition
= -1;
425 void wxWebViewIE::EnableHistory(bool enable
)
427 m_historyEnabled
= enable
;
428 m_historyList
.clear();
429 m_historyPosition
= -1;
432 void wxWebViewIE::Reload(wxWebViewReloadFlags flags
)
436 V_VT(&level
) = VT_I2
;
440 case wxWEB_VIEW_RELOAD_DEFAULT
:
441 V_I2(&level
) = REFRESH_NORMAL
;
443 case wxWEB_VIEW_RELOAD_NO_CACHE
:
444 V_I2(&level
) = REFRESH_COMPLETELY
;
447 wxFAIL_MSG("Unexpected reload type");
450 m_webBrowser
->Refresh2(&level
);
453 bool wxWebViewIE::IsOfflineMode()
455 wxVariant out
= m_ie
.GetProperty("Offline");
457 wxASSERT(out
.GetType() == "bool");
459 return out
.GetBool();
462 void wxWebViewIE::SetOfflineMode(bool offline
)
464 // FIXME: the wxWidgets docs do not really document what the return
465 // parameter of PutProperty is
466 const bool success
= m_ie
.PutProperty("Offline", (offline
?
472 bool wxWebViewIE::IsBusy()
474 if (m_isBusy
) return true;
476 wxVariant out
= m_ie
.GetProperty("Busy");
478 wxASSERT(out
.GetType() == "bool");
480 return out
.GetBool();
483 wxString
wxWebViewIE::GetCurrentURL()
485 wxVariant out
= m_ie
.GetProperty("LocationURL");
487 wxASSERT(out
.GetType() == "string");
488 return out
.GetString();
491 wxString
wxWebViewIE::GetCurrentTitle()
493 IHTMLDocument2
* document
= GetDocument();
496 document
->get_nameProp(&title
);
497 return wxString(title
);
500 bool wxWebViewIE::CanCut()
502 return CanExecCommand("Cut");
505 bool wxWebViewIE::CanCopy()
507 return CanExecCommand("Copy");
509 bool wxWebViewIE::CanPaste()
511 return CanExecCommand("Paste");
514 void wxWebViewIE::Cut()
519 void wxWebViewIE::Copy()
524 void wxWebViewIE::Paste()
526 ExecCommand("Paste");
529 bool wxWebViewIE::CanUndo()
531 return CanExecCommand("Undo");
533 bool wxWebViewIE::CanRedo()
535 return CanExecCommand("Redo");
538 void wxWebViewIE::Undo()
543 void wxWebViewIE::Redo()
548 void wxWebViewIE::SetEditable(bool enable
)
550 IHTMLDocument2
* document
= GetDocument();
552 document
->put_designMode(SysAllocString(L
"On"));
554 document
->put_designMode(SysAllocString(L
"Off"));
557 bool wxWebViewIE::IsEditable()
559 IHTMLDocument2
* document
= GetDocument();
561 document
->get_designMode(&mode
);
562 if(wxString(mode
) == "On")
568 void wxWebViewIE::SelectAll()
570 ExecCommand("SelectAll");
573 bool wxWebViewIE::HasSelection()
575 IHTMLDocument2
* document
= GetDocument();
576 IHTMLSelectionObject
* selection
;
577 document
->get_selection(&selection
);
579 selection
->get_type(&type
);
580 return wxString(type
) != "None";
583 void wxWebViewIE::DeleteSelection()
585 ExecCommand("Delete");
588 wxString
wxWebViewIE::GetSelectedText()
590 IHTMLDocument2
* document
= GetDocument();
591 IHTMLSelectionObject
* selection
;
593 HRESULT hr
= document
->get_selection(&selection
);
597 hr
= selection
->createRange(&disrange
);
600 IHTMLTxtRange
* range
;
601 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
605 range
->get_text(&text
);
606 selected
= wxString(text
);
611 selection
->Release();
617 bool wxWebViewIE::CanExecCommand(wxString command
)
619 IHTMLDocument2
* document
= GetDocument();
621 VARIANT_BOOL enabled
;
622 document
->queryCommandEnabled(SysAllocString(command
.wc_str()), &enabled
);
624 return (enabled
== VARIANT_TRUE
);
627 void wxWebViewIE::ExecCommand(wxString command
)
629 IHTMLDocument2
* document
= GetDocument();
630 document
->execCommand(SysAllocString(command
.wc_str()), VARIANT_FALSE
, VARIANT(), NULL
);
633 IHTMLDocument2
* wxWebViewIE::GetDocument()
635 wxVariant variant
= m_ie
.GetProperty("Document");
636 IHTMLDocument2
* document
= (IHTMLDocument2
*)variant
.GetVoidPtr();
643 void wxWebViewIE::onActiveXEvent(wxActiveXEvent
& evt
)
645 if (m_webBrowser
== NULL
) return;
647 switch (evt
.GetDispatchId())
649 case DISPID_BEFORENAVIGATE2
:
653 wxString url
= evt
[1].GetString();
654 wxString target
= evt
[3].GetString();
656 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING
,
657 GetId(), url
, target
, true);
658 event
.SetEventObject(this);
659 HandleWindowEvent(event
);
661 if (event
.IsVetoed())
663 wxActiveXEventNativeMSW
* nativeParams
=
664 evt
.GetNativeParameters();
665 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[0]) = VARIANT_TRUE
;
668 // at this point, either the navigation event has been cancelled
669 // and we're not busy, either it was accepted and IWebBrowser2's
670 // Busy property will be true; so we don't need our override
677 case DISPID_NAVIGATECOMPLETE2
:
679 wxString url
= evt
[1].GetString();
680 // TODO: set target parameter if possible
681 wxString target
= wxEmptyString
;
682 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
683 GetId(), url
, target
, false);
684 event
.SetEventObject(this);
685 HandleWindowEvent(event
);
689 case DISPID_PROGRESSCHANGE
:
695 case DISPID_DOCUMENTCOMPLETE
:
697 //Only send a complete even if we are actually finished, this brings
698 //the event in to line with webkit
700 m_webBrowser
->get_ReadyState( &rs
);
701 if(rs
!= READYSTATE_COMPLETE
)
704 wxString url
= evt
[1].GetString();
706 //As we are complete we also add to the history list, but not if the
707 //page is not the main page, ie it is a subframe
708 if(m_historyEnabled
&& !m_historyLoadingFromList
&& url
== GetCurrentURL())
710 //If we are not at the end of the list, then erase everything
711 //between us and the end before adding the new page
712 if(m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1)
714 m_historyList
.erase(m_historyList
.begin() + m_historyPosition
+ 1,
715 m_historyList
.end());
717 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(url
, GetCurrentTitle()));
718 m_historyList
.push_back(item
);
721 //Reset as we are done now
722 m_historyLoadingFromList
= false;
723 // TODO: set target parameter if possible
724 wxString target
= wxEmptyString
;
725 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_LOADED
, GetId(),
727 event
.SetEventObject(this);
728 HandleWindowEvent(event
);
732 case DISPID_STATUSTEXTCHANGE
:
737 case DISPID_TITLECHANGE
:
742 case DISPID_NAVIGATEERROR
:
744 wxWebNavigationError errorType
= wxWEB_NAV_ERR_OTHER
;
745 wxString errorCode
= "?";
746 switch (evt
[3].GetLong())
748 case INET_E_INVALID_URL
: // (0x800C0002L or -2146697214)
749 errorCode
= "INET_E_INVALID_URL";
750 errorType
= wxWEB_NAV_ERR_REQUEST
;
752 case INET_E_NO_SESSION
: // (0x800C0003L or -2146697213)
753 errorCode
= "INET_E_NO_SESSION";
754 errorType
= wxWEB_NAV_ERR_CONNECTION
;
756 case INET_E_CANNOT_CONNECT
: // (0x800C0004L or -2146697212)
757 errorCode
= "INET_E_CANNOT_CONNECT";
758 errorType
= wxWEB_NAV_ERR_CONNECTION
;
760 case INET_E_RESOURCE_NOT_FOUND
: // (0x800C0005L or -2146697211)
761 errorCode
= "INET_E_RESOURCE_NOT_FOUND";
762 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
764 case INET_E_OBJECT_NOT_FOUND
: // (0x800C0006L or -2146697210)
765 errorCode
= "INET_E_OBJECT_NOT_FOUND";
766 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
768 case INET_E_DATA_NOT_AVAILABLE
: // (0x800C0007L or -2146697209)
769 errorCode
= "INET_E_DATA_NOT_AVAILABLE";
770 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
772 case INET_E_DOWNLOAD_FAILURE
: // (0x800C0008L or -2146697208)
773 errorCode
= "INET_E_DOWNLOAD_FAILURE";
774 errorType
= wxWEB_NAV_ERR_CONNECTION
;
776 case INET_E_AUTHENTICATION_REQUIRED
: // (0x800C0009L or -2146697207)
777 errorCode
= "INET_E_AUTHENTICATION_REQUIRED";
778 errorType
= wxWEB_NAV_ERR_AUTH
;
780 case INET_E_NO_VALID_MEDIA
: // (0x800C000AL or -2146697206)
781 errorCode
= "INET_E_NO_VALID_MEDIA";
782 errorType
= wxWEB_NAV_ERR_REQUEST
;
784 case INET_E_CONNECTION_TIMEOUT
: // (0x800C000BL or -2146697205)
785 errorCode
= "INET_E_CONNECTION_TIMEOUT";
786 errorType
= wxWEB_NAV_ERR_CONNECTION
;
788 case INET_E_INVALID_REQUEST
: // (0x800C000CL or -2146697204)
789 errorCode
= "INET_E_INVALID_REQUEST";
790 errorType
= wxWEB_NAV_ERR_REQUEST
;
792 case INET_E_UNKNOWN_PROTOCOL
: // (0x800C000DL or -2146697203)
793 errorCode
= "INET_E_UNKNOWN_PROTOCOL";
794 errorType
= wxWEB_NAV_ERR_REQUEST
;
796 case INET_E_SECURITY_PROBLEM
: // (0x800C000EL or -2146697202)
797 errorCode
= "INET_E_SECURITY_PROBLEM";
798 errorType
= wxWEB_NAV_ERR_SECURITY
;
800 case INET_E_CANNOT_LOAD_DATA
: // (0x800C000FL or -2146697201)
801 errorCode
= "INET_E_CANNOT_LOAD_DATA";
802 errorType
= wxWEB_NAV_ERR_OTHER
;
804 case INET_E_CANNOT_INSTANTIATE_OBJECT
:
805 // CoCreateInstance will return an error code if this happens,
806 // we'll handle this above.
809 case INET_E_REDIRECT_FAILED
: // (0x800C0014L or -2146697196)
810 errorCode
= "INET_E_REDIRECT_FAILED";
811 errorType
= wxWEB_NAV_ERR_OTHER
;
813 case INET_E_REDIRECT_TO_DIR
: // (0x800C0015L or -2146697195)
814 errorCode
= "INET_E_REDIRECT_TO_DIR";
815 errorType
= wxWEB_NAV_ERR_REQUEST
;
817 case INET_E_CANNOT_LOCK_REQUEST
: // (0x800C0016L or -2146697194)
818 errorCode
= "INET_E_CANNOT_LOCK_REQUEST";
819 errorType
= wxWEB_NAV_ERR_OTHER
;
821 case INET_E_USE_EXTEND_BINDING
: // (0x800C0017L or -2146697193)
822 errorCode
= "INET_E_USE_EXTEND_BINDING";
823 errorType
= wxWEB_NAV_ERR_OTHER
;
825 case INET_E_TERMINATED_BIND
: // (0x800C0018L or -2146697192)
826 errorCode
= "INET_E_TERMINATED_BIND";
827 errorType
= wxWEB_NAV_ERR_OTHER
;
829 case INET_E_INVALID_CERTIFICATE
: // (0x800C0019L or -2146697191)
830 errorCode
= "INET_E_INVALID_CERTIFICATE";
831 errorType
= wxWEB_NAV_ERR_CERTIFICATE
;
833 case INET_E_CODE_DOWNLOAD_DECLINED
: // (0x800C0100L or -2146696960)
834 errorCode
= "INET_E_CODE_DOWNLOAD_DECLINED";
835 errorType
= wxWEB_NAV_ERR_USER_CANCELLED
;
837 case INET_E_RESULT_DISPATCHED
: // (0x800C0200L or -2146696704)
838 // cancel request cancelled...
839 errorCode
= "INET_E_RESULT_DISPATCHED";
840 errorType
= wxWEB_NAV_ERR_OTHER
;
842 case INET_E_CANNOT_REPLACE_SFP_FILE
: // (0x800C0300L or -2146696448)
843 errorCode
= "INET_E_CANNOT_REPLACE_SFP_FILE";
844 errorType
= wxWEB_NAV_ERR_SECURITY
;
846 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY
:
847 errorCode
= "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
848 errorType
= wxWEB_NAV_ERR_SECURITY
;
850 case INET_E_CODE_INSTALL_SUPPRESSED
:
851 errorCode
= "INET_E_CODE_INSTALL_SUPPRESSED";
852 errorType
= wxWEB_NAV_ERR_SECURITY
;
856 wxString url
= evt
[1].GetString();
857 wxString target
= evt
[2].GetString();
858 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_ERROR
, GetId(),
860 event
.SetEventObject(this);
861 event
.SetInt(errorType
);
862 event
.SetString(errorCode
);
863 HandleWindowEvent(event
);
867 case DISPID_COMMANDSTATECHANGE
:
869 long commandId
= evt
[0].GetLong();
870 bool enable
= evt
[1].GetBool();
871 if (commandId
== CSC_NAVIGATEBACK
)
873 m_canNavigateBack
= enable
;
875 else if (commandId
== CSC_NAVIGATEFORWARD
)
877 m_canNavigateForward
= enable
;
881 case DISPID_NEWWINDOW3
:
883 wxString url
= evt
[4].GetString();
885 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW
,
886 GetId(), url
, wxEmptyString
, true);
887 event
.SetEventObject(this);
888 HandleWindowEvent(event
);
890 //If we veto the event then we cancel the new window
891 if (event
.IsVetoed())
893 wxActiveXEventNativeMSW
* nativeParams
= evt
.GetNativeParameters();
894 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[3]) = VARIANT_TRUE
;