1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/webview_ie.cpp
3 // Purpose: wxMSW wxWebViewIE class implementation for web view component
4 // Author: Marianne Gagnon
5 // Copyright: (c) 2010 Marianne Gagnon, 2011 Steven Lamerton
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
12 #if defined(__BORLANDC__)
16 #include "wx/msw/webview_ie.h"
18 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
25 #include "wx/msw/registry.h"
26 #include "wx/msw/missing.h"
27 #include "wx/filesys.h"
28 #include "wx/dynlib.h"
32 /* These GUID definitions are our own implementation to support interfaces
33 * normally in urlmon.h. See include/wx/msw/webview_ie.h
38 DEFINE_GUID(wxIID_IInternetProtocolRoot
,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
39 DEFINE_GUID(wxIID_IInternetProtocol
,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
40 DEFINE_GUID(wxIID_IDocHostUIHandler
, 0xbd3f23c0, 0xd43e, 0x11cf, 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a);
41 DEFINE_GUID(wxIID_IHTMLElement2
,0x3050f434,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
42 DEFINE_GUID(wxIID_IMarkupServices
,0x3050f4a0,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
43 DEFINE_GUID(wxIID_IMarkupContainer
,0x3050f5f9,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
45 enum //Internal find flags
47 wxWEBVIEW_FIND_ADD_POINTERS
= 0x0001,
48 wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
= 0x0002
53 //Convenience function for error conversion
54 #define WX_ERROR_CASE(error, wxerror) \
56 event.SetString(#error); \
57 event.SetInt(wxerror); \
60 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewIE
, wxWebView
);
62 BEGIN_EVENT_TABLE(wxWebViewIE
, wxControl
)
63 EVT_ACTIVEX(wxID_ANY
, wxWebViewIE::onActiveXEvent
)
64 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg
)
67 bool wxWebViewIE::Create(wxWindow
* parent
,
75 if (!wxControl::Create(parent
, id
, pos
, size
, style
,
76 wxDefaultValidator
, name
))
83 m_historyLoadingFromList
= false;
84 m_historyEnabled
= true;
85 m_historyPosition
= -1;
86 m_zoomType
= wxWEBVIEW_ZOOM_TYPE_TEXT
;
89 if (::CoCreateInstance(CLSID_WebBrowser
, NULL
,
90 CLSCTX_INPROC_SERVER
, // CLSCTX_INPROC,
91 IID_IWebBrowser2
, (void**)&m_webBrowser
) != 0)
93 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
97 m_ie
.SetDispatchPtr(m_webBrowser
); // wxAutomationObject will release itself
99 m_webBrowser
->put_RegisterAsBrowser(VARIANT_TRUE
);
100 m_webBrowser
->put_RegisterAsDropTarget(VARIANT_TRUE
);
102 m_uiHandler
= new DocHostUIHandler(this);
104 m_container
= new wxIEContainer(this, IID_IWebBrowser2
, m_webBrowser
, m_uiHandler
);
106 EnableControlFeature(21 /* FEATURE_DISABLE_NAVIGATION_SOUNDS */);
112 wxWebViewIE::~wxWebViewIE()
114 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
115 if(urlMon
.HasSymbol(wxT("CoInternetGetSession")))
117 typedef HRESULT (WINAPI
*CoInternetGetSession_t
)(DWORD
,
118 wxIInternetSession
**,
120 wxDYNLIB_FUNCTION(CoInternetGetSession_t
, CoInternetGetSession
, urlMon
);
122 wxIInternetSession
* session
;
123 HRESULT res
= (*pfnCoInternetGetSession
)(0, &session
, 0);
126 wxFAIL_MSG("Could not retrive internet session");
129 for(unsigned int i
= 0; i
< m_factories
.size(); i
++)
131 session
->UnregisterNameSpace(m_factories
[i
],
132 (m_factories
[i
]->GetName()).wc_str());
133 m_factories
[i
]->Release();
139 void wxWebViewIE::LoadURL(const wxString
& url
)
141 m_ie
.CallMethod("Navigate", wxConvertStringToOle(url
));
144 void wxWebViewIE::DoSetPage(const wxString
& html
, const wxString
& baseUrl
)
146 BSTR bstr
= SysAllocString(OLESTR(""));
147 SAFEARRAY
*psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
148 if (psaStrings
!= NULL
)
151 HRESULT hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
153 param
->bstrVal
= bstr
;
155 hr
= SafeArrayUnaccessData(psaStrings
);
157 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
162 document
->write(psaStrings
);
165 SafeArrayDestroy(psaStrings
);
167 bstr
= SysAllocString(html
.wc_str());
169 // Creates a new one-dimensional array
170 psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
171 if (psaStrings
!= NULL
)
173 hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
175 param
->bstrVal
= bstr
;
176 hr
= SafeArrayUnaccessData(psaStrings
);
178 document
= GetDocument();
183 document
->write(psaStrings
);
185 // SafeArrayDestroy calls SysFreeString for each BSTR
186 SafeArrayDestroy(psaStrings
);
188 //We send the events when we are done to mimic webkit
190 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATED
,
191 GetId(), baseUrl
, "");
192 event
.SetEventObject(this);
193 HandleWindowEvent(event
);
195 //Document complete event
196 event
.SetEventType(wxEVT_WEBVIEW_LOADED
);
197 event
.SetEventObject(this);
198 HandleWindowEvent(event
);
202 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
207 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL during clear");
211 wxString
wxWebViewIE::GetPageSource() const
213 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
217 wxCOMPtr
<IHTMLElement
> bodyTag
;
218 wxCOMPtr
<IHTMLElement
> htmlTag
;
220 HRESULT hr
= document
->get_body(&bodyTag
);
223 hr
= bodyTag
->get_parentElement(&htmlTag
);
227 htmlTag
->get_outerHTML(&bstr
);
228 source
= wxString(bstr
);
239 wxWebViewZoom
wxWebViewIE::GetZoom() const
243 case wxWEBVIEW_ZOOM_TYPE_LAYOUT
:
244 return GetIEOpticalZoom();
245 case wxWEBVIEW_ZOOM_TYPE_TEXT
:
246 return GetIETextZoom();
251 //Dummy return to stop compiler warnings
252 return wxWEBVIEW_ZOOM_MEDIUM
;
256 void wxWebViewIE::SetZoom(wxWebViewZoom zoom
)
260 case wxWEBVIEW_ZOOM_TYPE_LAYOUT
:
261 SetIEOpticalZoom(zoom
);
263 case wxWEBVIEW_ZOOM_TYPE_TEXT
:
271 void wxWebViewIE::SetIETextZoom(wxWebViewZoom level
)
273 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
274 //is 0 to 4 so the check is unnecessary, these match exactly with the
277 VariantInit (&zoomVariant
);
278 V_VT(&zoomVariant
) = VT_I4
;
279 V_I4(&zoomVariant
) = level
;
284 m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
285 OLECMDEXECOPT_DONTPROMPTUSER
,
287 wxASSERT(result
== S_OK
);
290 wxWebViewZoom
wxWebViewIE::GetIETextZoom() const
293 VariantInit (&zoomVariant
);
294 V_VT(&zoomVariant
) = VT_I4
;
299 m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
300 OLECMDEXECOPT_DONTPROMPTUSER
,
302 wxASSERT(result
== S_OK
);
304 //We can safely cast here as we know that the range matches our enum
305 return static_cast<wxWebViewZoom
>(V_I4(&zoomVariant
));
308 void wxWebViewIE::SetIEOpticalZoom(wxWebViewZoom level
)
310 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
311 //is 10 to 1000 so the check is unnecessary
313 VariantInit (&zoomVariant
);
314 V_VT(&zoomVariant
) = VT_I4
;
316 //We make a somewhat arbitray map here, taken from values used by webkit
319 case wxWEBVIEW_ZOOM_TINY
:
320 V_I4(&zoomVariant
) = 60;
322 case wxWEBVIEW_ZOOM_SMALL
:
323 V_I4(&zoomVariant
) = 80;
325 case wxWEBVIEW_ZOOM_MEDIUM
:
326 V_I4(&zoomVariant
) = 100;
328 case wxWEBVIEW_ZOOM_LARGE
:
329 V_I4(&zoomVariant
) = 130;
331 case wxWEBVIEW_ZOOM_LARGEST
:
332 V_I4(&zoomVariant
) = 160;
341 m_webBrowser
->ExecWB((OLECMDID
)63 /*OLECMDID_OPTICAL_ZOOM*/,
342 OLECMDEXECOPT_DODEFAULT
,
345 wxASSERT(result
== S_OK
);
348 wxWebViewZoom
wxWebViewIE::GetIEOpticalZoom() const
351 VariantInit (&zoomVariant
);
352 V_VT(&zoomVariant
) = VT_I4
;
357 m_webBrowser
->ExecWB((OLECMDID
)63 /*OLECMDID_OPTICAL_ZOOM*/,
358 OLECMDEXECOPT_DODEFAULT
, NULL
,
360 wxASSERT(result
== S_OK
);
362 const int zoom
= V_I4(&zoomVariant
);
364 //We make a somewhat arbitray map here, taken from values used by webkit
367 return wxWEBVIEW_ZOOM_TINY
;
369 else if (zoom
> 65 && zoom
<= 90)
371 return wxWEBVIEW_ZOOM_SMALL
;
373 else if (zoom
> 90 && zoom
<= 115)
375 return wxWEBVIEW_ZOOM_MEDIUM
;
377 else if (zoom
> 115 && zoom
<= 145)
379 return wxWEBVIEW_ZOOM_LARGE
;
381 else /*if (zoom > 145) */ //Using else removes a compiler warning
383 return wxWEBVIEW_ZOOM_LARGEST
;
387 void wxWebViewIE::SetZoomType(wxWebViewZoomType type
)
392 wxWebViewZoomType
wxWebViewIE::GetZoomType() const
397 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type
) const
399 //IE 6 and below only support text zoom, so check the registry to see what
400 //version we actually have
401 wxRegKey
key(wxRegKey::HKLM
, "Software\\Microsoft\\Internet Explorer");
403 key
.QueryValue("Version", value
);
405 long version
= wxAtoi(value
.Left(1));
406 if(version
<= 6 && type
== wxWEBVIEW_ZOOM_TYPE_LAYOUT
)
412 void wxWebViewIE::Print()
414 m_webBrowser
->ExecWB(OLECMDID_PRINTPREVIEW
,
415 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
418 bool wxWebViewIE::CanGoBack() const
421 return m_historyPosition
> 0;
426 bool wxWebViewIE::CanGoForward() const
429 return m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1;
434 void wxWebViewIE::LoadHistoryItem(wxSharedPtr
<wxWebViewHistoryItem
> item
)
437 for(unsigned int i
= 0; i
< m_historyList
.size(); i
++)
439 //We compare the actual pointers to find the correct item
440 if(m_historyList
[i
].get() == item
.get())
443 wxASSERT_MSG(pos
!= static_cast<int>(m_historyList
.size()),
444 "invalid history item");
445 m_historyLoadingFromList
= true;
446 LoadURL(item
->GetUrl());
447 m_historyPosition
= pos
;
450 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > wxWebViewIE::GetBackwardHistory()
452 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > backhist
;
453 //As we don't have std::copy or an iterator constructor in the wxwidgets
454 //native vector we construct it by hand
455 for(int i
= 0; i
< m_historyPosition
; i
++)
457 backhist
.push_back(m_historyList
[i
]);
462 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > wxWebViewIE::GetForwardHistory()
464 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > forwardhist
;
465 //As we don't have std::copy or an iterator constructor in the wxwidgets
466 //native vector we construct it by hand
467 for(int i
= m_historyPosition
+ 1; i
< static_cast<int>(m_historyList
.size()); i
++)
469 forwardhist
.push_back(m_historyList
[i
]);
474 void wxWebViewIE::GoBack()
476 LoadHistoryItem(m_historyList
[m_historyPosition
- 1]);
479 void wxWebViewIE::GoForward()
481 LoadHistoryItem(m_historyList
[m_historyPosition
+ 1]);
484 void wxWebViewIE::Stop()
486 m_ie
.CallMethod("Stop");
489 void wxWebViewIE::ClearHistory()
491 m_historyList
.clear();
492 m_historyPosition
= -1;
495 void wxWebViewIE::EnableHistory(bool enable
)
497 m_historyEnabled
= enable
;
498 m_historyList
.clear();
499 m_historyPosition
= -1;
502 void wxWebViewIE::Reload(wxWebViewReloadFlags flags
)
506 V_VT(&level
) = VT_I2
;
510 case wxWEBVIEW_RELOAD_DEFAULT
:
511 V_I2(&level
) = REFRESH_NORMAL
;
513 case wxWEBVIEW_RELOAD_NO_CACHE
:
514 V_I2(&level
) = REFRESH_COMPLETELY
;
517 wxFAIL_MSG("Unexpected reload type");
520 m_webBrowser
->Refresh2(&level
);
523 bool wxWebViewIE::IsOfflineMode()
525 wxVariant out
= m_ie
.GetProperty("Offline");
527 wxASSERT(out
.GetType() == "bool");
529 return out
.GetBool();
532 void wxWebViewIE::SetOfflineMode(bool offline
)
534 // FIXME: the wxWidgets docs do not really document what the return
535 // parameter of PutProperty is
539 m_ie
.PutProperty("Offline", (offline
?
545 bool wxWebViewIE::IsBusy() const
547 if (m_isBusy
) return true;
549 wxVariant out
= m_ie
.GetProperty("Busy");
551 wxASSERT(out
.GetType() == "bool");
553 return out
.GetBool();
556 wxString
wxWebViewIE::GetCurrentURL() const
558 wxVariant out
= m_ie
.GetProperty("LocationURL");
560 wxASSERT(out
.GetType() == "string");
561 return out
.GetString();
564 wxString
wxWebViewIE::GetCurrentTitle() const
566 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
571 document
->get_nameProp(&title
);
572 return wxString(title
);
580 bool wxWebViewIE::CanCut() const
582 return CanExecCommand("Cut");
585 bool wxWebViewIE::CanCopy() const
587 return CanExecCommand("Copy");
590 bool wxWebViewIE::CanPaste() const
592 return CanExecCommand("Paste");
595 void wxWebViewIE::Cut()
600 void wxWebViewIE::Copy()
605 void wxWebViewIE::Paste()
607 ExecCommand("Paste");
610 bool wxWebViewIE::CanUndo() const
612 return CanExecCommand("Undo");
615 bool wxWebViewIE::CanRedo() const
617 return CanExecCommand("Redo");
620 void wxWebViewIE::Undo()
625 void wxWebViewIE::Redo()
630 long wxWebViewIE::Find(const wxString
& text
, int flags
)
632 //If the text is empty then we clear.
636 if(m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
638 FindInternal(m_findText
, (m_findFlags
&~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT
), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
);
643 //Have we done this search before?
644 if(m_findText
== text
)
646 //Just do a highlight?
647 if((flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
) != (m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
))
650 if(!m_findPointers
.empty())
652 FindInternal(m_findText
, m_findFlags
, ((flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
) == 0 ? wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
: 0));
654 return m_findPosition
;
656 else if(((m_findFlags
& wxWEBVIEW_FIND_ENTIRE_WORD
) == (flags
& wxWEBVIEW_FIND_ENTIRE_WORD
)) && ((m_findFlags
& wxWEBVIEW_FIND_MATCH_CASE
) == (flags
&wxWEBVIEW_FIND_MATCH_CASE
)))
659 return FindNext(((flags
& wxWEBVIEW_FIND_BACKWARDS
) ? -1 : 1));
662 //Remove old highlight if any.
663 if(m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
665 FindInternal(m_findText
, (m_findFlags
&~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT
), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
);
667 //Reset find variables.
672 //find the text and return wxNOT_FOUND if there are no matches.
673 FindInternal(text
, flags
, wxWEBVIEW_FIND_ADD_POINTERS
);
674 if(m_findPointers
.empty())
677 // Or their number if there are.
678 return m_findPointers
.size();
681 void wxWebViewIE::SetEditable(bool enable
)
683 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
688 document
->put_designMode(SysAllocString(L
"On"));
690 document
->put_designMode(SysAllocString(L
"Off"));
695 bool wxWebViewIE::IsEditable() const
697 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
702 document
->get_designMode(&mode
);
703 if(wxString(mode
) == "On")
714 void wxWebViewIE::SelectAll()
716 ExecCommand("SelectAll");
719 bool wxWebViewIE::HasSelection() const
721 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
725 wxCOMPtr
<IHTMLSelectionObject
> selection
;
727 HRESULT hr
= document
->get_selection(&selection
);
731 selection
->get_type(&type
);
732 sel
= wxString(type
);
734 return sel
!= "None";
742 void wxWebViewIE::DeleteSelection()
744 ExecCommand("Delete");
747 wxString
wxWebViewIE::GetSelectedText() const
749 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
753 wxCOMPtr
<IHTMLSelectionObject
> selection
;
755 HRESULT hr
= document
->get_selection(&selection
);
758 wxCOMPtr
<IDispatch
> disrange
;
759 hr
= selection
->createRange(&disrange
);
762 wxCOMPtr
<IHTMLTxtRange
> range
;
763 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
767 range
->get_text(&text
);
768 selected
= wxString(text
);
780 wxString
wxWebViewIE::GetSelectedSource() const
782 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
786 wxCOMPtr
<IHTMLSelectionObject
> selection
;
788 HRESULT hr
= document
->get_selection(&selection
);
791 wxCOMPtr
<IDispatch
> disrange
;
792 hr
= selection
->createRange(&disrange
);
795 wxCOMPtr
<IHTMLTxtRange
> range
;
796 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
800 range
->get_htmlText(&text
);
801 selected
= wxString(text
);
813 void wxWebViewIE::ClearSelection()
815 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
819 wxCOMPtr
<IHTMLSelectionObject
> selection
;
821 HRESULT hr
= document
->get_selection(&selection
);
829 wxString
wxWebViewIE::GetPageText() const
831 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
836 wxCOMPtr
<IHTMLElement
> body
;
837 HRESULT hr
= document
->get_body(&body
);
841 body
->get_innerText(&out
);
842 text
= wxString(out
);
852 void wxWebViewIE::RunScript(const wxString
& javascript
)
854 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
858 wxCOMPtr
<IHTMLWindow2
> window
;
859 wxString language
= "javascript";
860 HRESULT hr
= document
->get_parentWindow(&window
);
865 V_VT(&level
) = VT_EMPTY
;
866 window
->execScript(SysAllocString(javascript
.wc_str()),
867 SysAllocString(language
.wc_str()),
873 void wxWebViewIE::RegisterHandler(wxSharedPtr
<wxWebViewHandler
> handler
)
875 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
876 if(urlMon
.HasSymbol(wxT("CoInternetGetSession")))
878 typedef HRESULT (WINAPI
*CoInternetGetSession_t
)(DWORD
, wxIInternetSession
**, DWORD
);
879 wxDYNLIB_FUNCTION(CoInternetGetSession_t
, CoInternetGetSession
, urlMon
);
881 ClassFactory
* cf
= new ClassFactory(handler
);
882 wxIInternetSession
* session
;
883 HRESULT res
= (*pfnCoInternetGetSession
)(0, &session
, 0);
886 wxFAIL_MSG("Could not retrive internet session");
889 HRESULT hr
= session
->RegisterNameSpace(cf
, CLSID_FileProtocol
,
890 handler
->GetName().wc_str(),
894 wxFAIL_MSG("Could not register protocol");
896 m_factories
.push_back(cf
);
900 wxFAIL_MSG("urlmon does not contain CoInternetGetSession");
904 bool wxWebViewIE::CanExecCommand(wxString command
) const
906 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
910 VARIANT_BOOL enabled
;
912 document
->queryCommandEnabled(SysAllocString(command
.wc_str()), &enabled
);
914 return (enabled
== VARIANT_TRUE
);
923 void wxWebViewIE::ExecCommand(wxString command
)
925 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
929 document
->execCommand(SysAllocString(command
.wc_str()), VARIANT_FALSE
, VARIANT(), NULL
);
933 wxCOMPtr
<IHTMLDocument2
> wxWebViewIE::GetDocument() const
935 wxCOMPtr
<IDispatch
> dispatch
;
936 wxCOMPtr
<IHTMLDocument2
> document
;
937 HRESULT result
= m_webBrowser
->get_Document(&dispatch
);
938 if(dispatch
&& SUCCEEDED(result
))
940 //document is set to null automatically if the interface isn't supported
941 dispatch
->QueryInterface(IID_IHTMLDocument2
, (void**)&document
);
946 bool wxWebViewIE::IsElementVisible(wxCOMPtr
<IHTMLElement
> elm
)
948 wxCOMPtr
<IHTMLElement
> elm1
= elm
;
950 bool is_visible
= true;
951 //This method is not perfect but it does discover most of the hidden elements.
952 //so if a better solution is found, then please do improve.
955 wxCOMPtr
<wxIHTMLElement2
> elm2
;
956 if(SUCCEEDED(elm1
->QueryInterface(wxIID_IHTMLElement2
, (void**) &elm2
)))
958 wxCOMPtr
<wxIHTMLCurrentStyle
> style
;
959 if(SUCCEEDED(elm2
->get_currentStyle(&style
)))
961 //Check if the object has the style display:none.
962 if((style
->get_display(&tmp_bstr
) != S_OK
) ||
963 (tmp_bstr
!= NULL
&& (_wcsicmp(tmp_bstr
, L
"none") == 0)))
967 //Check if the object has the style visibility:hidden.
968 if((is_visible
&& (style
->get_visibility(&tmp_bstr
) != S_OK
)) ||
969 (tmp_bstr
!= NULL
&& _wcsicmp(tmp_bstr
, L
"hidden") == 0))
978 //Lets check the object's parent element.
979 IHTMLElement
* parent
;
980 if(is_visible
&& SUCCEEDED(elm1
->get_parentElement(&parent
)))
993 void wxWebViewIE::FindInternal(const wxString
& text
, int flags
, int internal_flag
)
996 wxCOMPtr
<wxIMarkupServices
> pIMS
;
997 wxCOMPtr
<IHTMLDocument2
> document
= GetDocument();
999 //This function does the acutal work.
1000 if(document
&& SUCCEEDED(document
->QueryInterface(wxIID_IMarkupServices
, (void **)&pIMS
)))
1002 wxCOMPtr
<wxIMarkupContainer
> pIMC
;
1003 if(SUCCEEDED(document
->QueryInterface(wxIID_IMarkupContainer
, (void **)&pIMC
)))
1005 wxCOMPtr
<wxIMarkupPointer
> ptrBegin
, ptrEnd
;
1006 BSTR attr_bstr
= SysAllocString(L
"style=\"background-color:#ffff00\"");
1007 BSTR text_bstr
= SysAllocString(text
.wc_str());
1008 pIMS
->CreateMarkupPointer(&ptrBegin
);
1009 pIMS
->CreateMarkupPointer(&ptrEnd
);
1011 ptrBegin
->SetGravity(wxPOINTER_GRAVITY_Right
);
1012 ptrBegin
->MoveToContainer(pIMC
, TRUE
);
1013 //Create the find flag from the wx one.
1014 if(flags
& wxWEBVIEW_FIND_ENTIRE_WORD
)
1016 find_flag
|= wxFINDTEXT_WHOLEWORD
;
1018 if(flags
& wxWEBVIEW_FIND_MATCH_CASE
)
1020 find_flag
|= wxFINDTEXT_MATCHCASE
;
1023 //A little speed-up to avoid to re-alloc in the positions vector.
1024 if(text
.Len() < 3 && m_findPointers
.capacity() < 500)
1026 m_findPointers
.reserve(text
.Len() == 1 ? 1000 : 500);
1029 while(ptrBegin
->FindText(text_bstr
, find_flag
, ptrEnd
, NULL
) == S_OK
)
1031 wxCOMPtr
<IHTMLElement
> elm
;
1032 if(ptrBegin
->CurrentScope(&elm
) == S_OK
)
1034 if(IsElementVisible(elm
))
1036 //Highlight the word if the flag was set.
1037 if(flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
1039 IHTMLElement
* pFontEl
;
1040 pIMS
->CreateElement(wxTAGID_FONT
, attr_bstr
, &pFontEl
);
1041 pIMS
->InsertElement(pFontEl
, ptrBegin
, ptrEnd
);
1043 if(internal_flag
& wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
)
1045 IHTMLElement
* pFontEl
;
1046 ptrBegin
->CurrentScope(&pFontEl
);
1047 pIMS
->RemoveElement(pFontEl
);
1050 if(internal_flag
& wxWEBVIEW_FIND_ADD_POINTERS
)
1052 wxIMarkupPointer
*cptrBegin
, *cptrEnd
;
1053 pIMS
->CreateMarkupPointer(&cptrBegin
);
1054 pIMS
->CreateMarkupPointer(&cptrEnd
);
1055 cptrBegin
->MoveToPointer(ptrBegin
);
1056 cptrEnd
->MoveToPointer(ptrEnd
);
1057 m_findPointers
.push_back(wxFindPointers(cptrBegin
,cptrEnd
));
1061 ptrBegin
->MoveToPointer(ptrEnd
);
1064 SysFreeString(text_bstr
);
1065 SysFreeString(attr_bstr
);
1070 long wxWebViewIE::FindNext(int direction
)
1072 //Don't bother if we have no pointers set.
1073 if(m_findPointers
.empty())
1077 //Manage the find position and do some checks.
1087 if(m_findPosition
>= (signed)m_findPointers
.size())
1089 if(m_findFlags
& wxWEBVIEW_FIND_WRAP
)
1099 else if(m_findPosition
< 0)
1101 if(m_findFlags
& wxWEBVIEW_FIND_WRAP
)
1103 m_findPosition
= m_findPointers
.size()-1;
1112 wxCOMPtr
<IHTMLDocument2
> document
= GetDocument();
1113 wxCOMPtr
<IHTMLElement
> body_element
;
1116 //Now try to create a range from the body.
1117 if(document
&& SUCCEEDED(document
->get_body(&body_element
)))
1119 wxCOMPtr
<IHTMLBodyElement
> body
;
1120 if(SUCCEEDED(body_element
->QueryInterface(IID_IHTMLBodyElement
,(void**)&body
)))
1122 wxCOMPtr
<wxIHTMLTxtRange
> range
;
1123 if(SUCCEEDED(body
->createTextRange((IHTMLTxtRange
**)(&range
))))
1125 wxCOMPtr
<wxIMarkupServices
> pIMS
;
1126 //So far so good, now we try to position our find pointers.
1127 if(SUCCEEDED(document
->QueryInterface(wxIID_IMarkupServices
,(void **)&pIMS
)))
1129 wxIMarkupPointer
*begin
= m_findPointers
[m_findPosition
].begin
, *end
= m_findPointers
[m_findPosition
].end
;
1130 if(pIMS
->MoveRangeToPointers(begin
,end
,range
) == S_OK
&& range
->select() == S_OK
)
1132 ret
= m_findPosition
;
1141 void wxWebViewIE::FindClear()
1143 //Reset find variables.
1145 m_findFlags
= wxWEBVIEW_FIND_DEFAULT
;
1146 m_findPosition
= -1;
1148 //The m_findPointers contains pointers for the found text.
1149 //Since it uses ref counting we call release on the pointers first
1150 //before we remove them from the vector. In other words do not just
1151 //remove elements from m_findPointers without calling release first
1152 //or you will get a memory leak.
1153 size_t count
= m_findPointers
.size();
1154 for(size_t i
= 0; i
< count
; i
++)
1156 m_findPointers
[i
].begin
->Release();
1157 m_findPointers
[i
].end
->Release();
1159 m_findPointers
.clear();
1162 bool wxWebViewIE::EnableControlFeature(long flag
, bool enable
)
1164 #if wxUSE_DYNLIB_CLASS
1166 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
1167 if( urlMon
.IsLoaded() &&
1168 urlMon
.HasSymbol("CoInternetSetFeatureEnabled") &&
1169 urlMon
.HasSymbol("CoInternetIsFeatureEnabled"))
1171 typedef HRESULT (WINAPI
*CoInternetSetFeatureEnabled_t
)(DWORD
, DWORD
, BOOL
);
1172 typedef HRESULT (WINAPI
*CoInternetIsFeatureEnabled_t
)(DWORD
, DWORD
);
1174 wxDYNLIB_FUNCTION(CoInternetSetFeatureEnabled_t
, CoInternetSetFeatureEnabled
, urlMon
);
1175 wxDYNLIB_FUNCTION(CoInternetIsFeatureEnabled_t
, CoInternetIsFeatureEnabled
, urlMon
);
1177 HRESULT hr
= (*pfnCoInternetIsFeatureEnabled
)(flag
,
1178 0x2 /* SET_FEATURE_ON_PROCESS */);
1179 if((hr
== S_OK
&& enable
) || (hr
== S_FALSE
&& !enable
))
1182 hr
= (*pfnCoInternetSetFeatureEnabled
)(flag
,
1183 0x2/* SET_FEATURE_ON_PROCESS */,
1184 (enable
? TRUE
: FALSE
));
1187 wxLogApiError(wxT("CoInternetSetFeatureEnabled"), hr
);
1195 wxUnusedVar(enable
);
1197 #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
1200 void wxWebViewIE::onActiveXEvent(wxActiveXEvent
& evt
)
1202 if (m_webBrowser
== NULL
) return;
1204 switch (evt
.GetDispatchId())
1206 case DISPID_BEFORENAVIGATE2
:
1210 wxString url
= evt
[1].GetString();
1211 wxString target
= evt
[3].GetString();
1213 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATING
,
1214 GetId(), url
, target
);
1216 //skip empty javascript events.
1217 if(url
== "javascript:\"\"" && target
.IsEmpty())
1223 event
.SetEventObject(this);
1224 HandleWindowEvent(event
);
1227 if (!event
.IsAllowed())
1229 wxActiveXEventNativeMSW
* nativeParams
=
1230 evt
.GetNativeParameters();
1231 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[0]) = VARIANT_TRUE
;
1234 // at this point, either the navigation event has been cancelled
1235 // and we're not busy, either it was accepted and IWebBrowser2's
1236 // Busy property will be true; so we don't need our override
1243 case DISPID_NAVIGATECOMPLETE2
:
1245 wxString url
= evt
[1].GetString();
1246 // TODO: set target parameter if possible
1247 wxString target
= wxEmptyString
;
1248 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATED
,
1249 GetId(), url
, target
);
1250 event
.SetEventObject(this);
1251 HandleWindowEvent(event
);
1255 case DISPID_PROGRESSCHANGE
:
1257 // download progress
1261 case DISPID_DOCUMENTCOMPLETE
:
1263 //Only send a complete even if we are actually finished, this brings
1264 //the event in to line with webkit
1266 m_webBrowser
->get_ReadyState( &rs
);
1267 if(rs
!= READYSTATE_COMPLETE
)
1270 wxString url
= evt
[1].GetString();
1272 //As we are complete we also add to the history list, but not if the
1273 //page is not the main page, ie it is a subframe
1274 //We also have to check if we are loading a file:// url, if so we
1275 //need to change the comparison as ie passes back a different style
1277 if(m_historyEnabled
&& !m_historyLoadingFromList
&&
1278 (url
== GetCurrentURL() ||
1279 (GetCurrentURL().substr(0, 4) == "file" &&
1280 wxFileSystem::URLToFileName(GetCurrentURL()).GetFullPath() == url
)))
1282 //If we are not at the end of the list, then erase everything
1283 //between us and the end before adding the new page
1284 if(m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1)
1286 m_historyList
.erase(m_historyList
.begin() + m_historyPosition
+ 1,
1287 m_historyList
.end());
1289 wxSharedPtr
<wxWebViewHistoryItem
> item(new wxWebViewHistoryItem(url
, GetCurrentTitle()));
1290 m_historyList
.push_back(item
);
1291 m_historyPosition
++;
1293 //Reset as we are done now
1294 m_historyLoadingFromList
= false;
1295 //Reset the find values.
1297 // TODO: set target parameter if possible
1298 wxString target
= wxEmptyString
;
1299 wxWebViewEvent
event(wxEVT_WEBVIEW_LOADED
, GetId(),
1301 event
.SetEventObject(this);
1302 HandleWindowEvent(event
);
1306 case DISPID_STATUSTEXTCHANGE
:
1311 case DISPID_TITLECHANGE
:
1313 wxString title
= evt
[0].GetString();
1315 wxWebViewEvent
event(wxEVT_WEBVIEW_TITLE_CHANGED
,
1316 GetId(), GetCurrentURL(), "");
1317 event
.SetString(title
);
1318 event
.SetEventObject(this);
1319 HandleWindowEvent(event
);
1323 case DISPID_NAVIGATEERROR
:
1325 wxWebViewEvent
event(wxEVT_WEBVIEW_ERROR
, GetId(),
1326 evt
[1].GetString(), evt
[2].GetString());
1327 event
.SetEventObject(this);
1329 switch (evt
[3].GetLong())
1332 WX_ERROR_CASE(HTTP_STATUS_BAD_REQUEST
, wxWEBVIEW_NAV_ERR_REQUEST
)
1333 WX_ERROR_CASE(HTTP_STATUS_DENIED
, wxWEBVIEW_NAV_ERR_AUTH
)
1334 WX_ERROR_CASE(HTTP_STATUS_PAYMENT_REQ
, wxWEBVIEW_NAV_ERR_OTHER
)
1335 WX_ERROR_CASE(HTTP_STATUS_FORBIDDEN
, wxWEBVIEW_NAV_ERR_AUTH
)
1336 WX_ERROR_CASE(HTTP_STATUS_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1337 WX_ERROR_CASE(HTTP_STATUS_BAD_METHOD
, wxWEBVIEW_NAV_ERR_REQUEST
)
1338 WX_ERROR_CASE(HTTP_STATUS_NONE_ACCEPTABLE
, wxWEBVIEW_NAV_ERR_OTHER
)
1339 WX_ERROR_CASE(HTTP_STATUS_PROXY_AUTH_REQ
, wxWEBVIEW_NAV_ERR_AUTH
)
1340 WX_ERROR_CASE(HTTP_STATUS_REQUEST_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1341 WX_ERROR_CASE(HTTP_STATUS_CONFLICT
, wxWEBVIEW_NAV_ERR_REQUEST
)
1342 WX_ERROR_CASE(HTTP_STATUS_GONE
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1343 WX_ERROR_CASE(HTTP_STATUS_LENGTH_REQUIRED
, wxWEBVIEW_NAV_ERR_REQUEST
)
1344 WX_ERROR_CASE(HTTP_STATUS_PRECOND_FAILED
, wxWEBVIEW_NAV_ERR_REQUEST
)
1345 WX_ERROR_CASE(HTTP_STATUS_REQUEST_TOO_LARGE
, wxWEBVIEW_NAV_ERR_REQUEST
)
1346 WX_ERROR_CASE(HTTP_STATUS_URI_TOO_LONG
, wxWEBVIEW_NAV_ERR_REQUEST
)
1347 WX_ERROR_CASE(HTTP_STATUS_UNSUPPORTED_MEDIA
, wxWEBVIEW_NAV_ERR_REQUEST
)
1348 WX_ERROR_CASE(HTTP_STATUS_RETRY_WITH
, wxWEBVIEW_NAV_ERR_OTHER
)
1350 // 500 - Error codes
1351 WX_ERROR_CASE(HTTP_STATUS_SERVER_ERROR
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1352 WX_ERROR_CASE(HTTP_STATUS_NOT_SUPPORTED
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1353 WX_ERROR_CASE(HTTP_STATUS_BAD_GATEWAY
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1354 WX_ERROR_CASE(HTTP_STATUS_SERVICE_UNAVAIL
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1355 WX_ERROR_CASE(HTTP_STATUS_GATEWAY_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1356 WX_ERROR_CASE(HTTP_STATUS_VERSION_NOT_SUP
, wxWEBVIEW_NAV_ERR_REQUEST
)
1358 // URL Moniker error codes
1359 WX_ERROR_CASE(INET_E_INVALID_URL
, wxWEBVIEW_NAV_ERR_REQUEST
)
1360 WX_ERROR_CASE(INET_E_NO_SESSION
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1361 WX_ERROR_CASE(INET_E_CANNOT_CONNECT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1362 WX_ERROR_CASE(INET_E_RESOURCE_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1363 WX_ERROR_CASE(INET_E_OBJECT_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1364 WX_ERROR_CASE(INET_E_DATA_NOT_AVAILABLE
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1365 WX_ERROR_CASE(INET_E_DOWNLOAD_FAILURE
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1366 WX_ERROR_CASE(INET_E_AUTHENTICATION_REQUIRED
, wxWEBVIEW_NAV_ERR_AUTH
)
1367 WX_ERROR_CASE(INET_E_NO_VALID_MEDIA
, wxWEBVIEW_NAV_ERR_REQUEST
)
1368 WX_ERROR_CASE(INET_E_CONNECTION_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1369 WX_ERROR_CASE(INET_E_INVALID_REQUEST
, wxWEBVIEW_NAV_ERR_REQUEST
)
1370 WX_ERROR_CASE(INET_E_UNKNOWN_PROTOCOL
, wxWEBVIEW_NAV_ERR_REQUEST
)
1371 WX_ERROR_CASE(INET_E_SECURITY_PROBLEM
, wxWEBVIEW_NAV_ERR_SECURITY
)
1372 WX_ERROR_CASE(INET_E_CANNOT_LOAD_DATA
, wxWEBVIEW_NAV_ERR_OTHER
)
1373 WX_ERROR_CASE(INET_E_REDIRECT_FAILED
, wxWEBVIEW_NAV_ERR_OTHER
)
1374 WX_ERROR_CASE(INET_E_REDIRECT_TO_DIR
, wxWEBVIEW_NAV_ERR_REQUEST
)
1375 WX_ERROR_CASE(INET_E_CANNOT_LOCK_REQUEST
, wxWEBVIEW_NAV_ERR_OTHER
)
1376 WX_ERROR_CASE(INET_E_USE_EXTEND_BINDING
, wxWEBVIEW_NAV_ERR_OTHER
)
1377 WX_ERROR_CASE(INET_E_TERMINATED_BIND
, wxWEBVIEW_NAV_ERR_OTHER
)
1378 WX_ERROR_CASE(INET_E_INVALID_CERTIFICATE
, wxWEBVIEW_NAV_ERR_CERTIFICATE
)
1379 WX_ERROR_CASE(INET_E_CODE_DOWNLOAD_DECLINED
, wxWEBVIEW_NAV_ERR_USER_CANCELLED
)
1380 WX_ERROR_CASE(INET_E_RESULT_DISPATCHED
, wxWEBVIEW_NAV_ERR_OTHER
)
1381 WX_ERROR_CASE(INET_E_CANNOT_REPLACE_SFP_FILE
, wxWEBVIEW_NAV_ERR_SECURITY
)
1382 WX_ERROR_CASE(INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY
, wxWEBVIEW_NAV_ERR_SECURITY
)
1383 WX_ERROR_CASE(INET_E_CODE_INSTALL_SUPPRESSED
, wxWEBVIEW_NAV_ERR_SECURITY
)
1385 HandleWindowEvent(event
);
1388 case DISPID_NEWWINDOW3
:
1390 wxString url
= evt
[4].GetString();
1392 wxWebViewEvent
event(wxEVT_WEBVIEW_NEWWINDOW
,
1393 GetId(), url
, wxEmptyString
);
1394 event
.SetEventObject(this);
1395 HandleWindowEvent(event
);
1397 //We always cancel this event otherwise an Internet Exporer window
1398 //is opened for the url
1399 wxActiveXEventNativeMSW
* nativeParams
= evt
.GetNativeParameters();
1400 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[3]) = VARIANT_TRUE
;
1408 VirtualProtocol::VirtualProtocol(wxSharedPtr
<wxWebViewHandler
> handler
)
1411 m_handler
= handler
;
1414 BEGIN_IID_TABLE(VirtualProtocol
)
1416 ADD_RAW_IID(wxIID_IInternetProtocolRoot
)
1417 ADD_RAW_IID(wxIID_IInternetProtocol
)
1420 IMPLEMENT_IUNKNOWN_METHODS(VirtualProtocol
)
1422 HRESULT STDMETHODCALLTYPE
VirtualProtocol::Start(LPCWSTR szUrl
, wxIInternetProtocolSink
*pOIProtSink
,
1423 wxIInternetBindInfo
*pOIBindInfo
, DWORD grfPI
,
1424 HANDLE_PTR dwReserved
)
1427 wxUnusedVar(pOIBindInfo
);
1429 wxUnusedVar(dwReserved
);
1430 m_protocolSink
= pOIProtSink
;
1432 //We get the file itself from the protocol handler
1433 m_file
= m_handler
->GetFile(szUrl
);
1437 return INET_E_RESOURCE_NOT_FOUND
;
1439 //We return the stream length for current and total size as we can always
1440 //read the whole file from the stream
1441 wxFileOffset length
= m_file
->GetStream()->GetLength();
1442 m_protocolSink
->ReportData(wxBSCF_FIRSTDATANOTIFICATION
|
1443 wxBSCF_DATAFULLYAVAILABLE
|
1444 wxBSCF_LASTDATANOTIFICATION
,
1449 HRESULT STDMETHODCALLTYPE
VirtualProtocol::Read(void *pv
, ULONG cb
, ULONG
*pcbRead
)
1451 //If the file is null we return false to indicte it is finished
1455 wxStreamError err
= m_file
->GetStream()->Read(pv
, cb
).GetLastError();
1456 *pcbRead
= m_file
->GetStream()->LastRead();
1458 if(err
== wxSTREAM_NO_ERROR
)
1463 m_protocolSink
->ReportResult(S_OK
, 0, NULL
);
1465 //As we are not eof there is more data
1468 else if(err
== wxSTREAM_EOF
)
1471 m_protocolSink
->ReportResult(S_OK
, 0, NULL
);
1472 //We are eof and so finished
1475 else if(err
== wxSTREAM_READ_ERROR
)
1478 return INET_E_DOWNLOAD_FAILURE
;
1482 //Dummy return to suppress a compiler warning
1484 return INET_E_DOWNLOAD_FAILURE
;
1488 BEGIN_IID_TABLE(ClassFactory
)
1490 ADD_IID(ClassFactory
)
1493 IMPLEMENT_IUNKNOWN_METHODS(ClassFactory
)
1495 HRESULT STDMETHODCALLTYPE
ClassFactory::CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
,
1499 return CLASS_E_NOAGGREGATION
;
1500 VirtualProtocol
* vp
= new VirtualProtocol(m_handler
);
1502 HRESULT hr
= vp
->QueryInterface(riid
, ppvObject
);
1508 STDMETHODIMP
ClassFactory::LockServer(BOOL fLock
)
1514 wxIEContainer::wxIEContainer(wxWindow
*parent
, REFIID iid
, IUnknown
*pUnk
,
1515 DocHostUIHandler
* uiHandler
) :
1516 wxActiveXContainer(parent
,iid
,pUnk
)
1518 m_uiHandler
= uiHandler
;
1521 wxIEContainer::~wxIEContainer()
1525 bool wxIEContainer::QueryClientSiteInterface(REFIID iid
, void **_interface
,
1528 if (m_uiHandler
&& IsEqualIID(iid
, wxIID_IDocHostUIHandler
))
1530 *_interface
= (IUnknown
*) (wxIDocHostUIHandler
*) m_uiHandler
;
1531 desc
= "IDocHostUIHandler";
1537 HRESULT wxSTDCALL
DocHostUIHandler::ShowContextMenu(DWORD dwID
, POINT
*ppt
,
1538 IUnknown
*pcmdtReserved
,
1539 IDispatch
*pdispReserved
)
1543 wxUnusedVar(pcmdtReserved
);
1544 wxUnusedVar(pdispReserved
);
1545 if(m_browser
->IsContextMenuEnabled())
1551 HRESULT wxSTDCALL
DocHostUIHandler::GetHostInfo(DOCHOSTUIINFO
*pInfo
)
1553 //don't show 3d border and enable themes.
1554 pInfo
->dwFlags
= pInfo
->dwFlags
| DOCHOSTUIFLAG_NO3DBORDER
| DOCHOSTUIFLAG_THEME
;
1558 HRESULT wxSTDCALL
DocHostUIHandler::ShowUI(DWORD dwID
,
1559 IOleInPlaceActiveObject
*pActiveObject
,
1560 IOleCommandTarget
*pCommandTarget
,
1561 IOleInPlaceFrame
*pFrame
,
1562 IOleInPlaceUIWindow
*pDoc
)
1565 wxUnusedVar(pActiveObject
);
1566 wxUnusedVar(pCommandTarget
);
1567 wxUnusedVar(pFrame
);
1572 HRESULT wxSTDCALL
DocHostUIHandler::HideUI(void)
1577 HRESULT wxSTDCALL
DocHostUIHandler::UpdateUI(void)
1582 HRESULT wxSTDCALL
DocHostUIHandler::EnableModeless(BOOL fEnable
)
1584 wxUnusedVar(fEnable
);
1588 HRESULT wxSTDCALL
DocHostUIHandler::OnDocWindowActivate(BOOL fActivate
)
1590 wxUnusedVar(fActivate
);
1594 HRESULT wxSTDCALL
DocHostUIHandler::OnFrameWindowActivate(BOOL fActivate
)
1596 wxUnusedVar(fActivate
);
1600 HRESULT wxSTDCALL
DocHostUIHandler::ResizeBorder(LPCRECT prcBorder
,
1601 IOleInPlaceUIWindow
*pUIWindow
,
1604 wxUnusedVar(prcBorder
);
1605 wxUnusedVar(pUIWindow
);
1606 wxUnusedVar(fFrameWindow
);
1610 HRESULT wxSTDCALL
DocHostUIHandler::TranslateAccelerator(LPMSG lpMsg
,
1611 const GUID
*pguidCmdGroup
,
1614 if(lpMsg
&& lpMsg
->message
== WM_KEYDOWN
)
1616 // check control is down but that it isn't right-alt which is mapped to
1618 if(GetKeyState(VK_CONTROL
) & 0x8000 &&
1619 !(GetKeyState(VK_MENU
) & 0x8000))
1621 //skip the accelerators used by the control
1622 switch(lpMsg
->wParam
)
1633 if(lpMsg
->wParam
== VK_F5
)
1639 wxUnusedVar(pguidCmdGroup
);
1640 wxUnusedVar(nCmdID
);
1644 HRESULT wxSTDCALL
DocHostUIHandler::GetOptionKeyPath(LPOLESTR
*pchKey
,DWORD dw
)
1646 wxUnusedVar(pchKey
);
1651 HRESULT wxSTDCALL
DocHostUIHandler::GetDropTarget(IDropTarget
*pDropTarget
,
1652 IDropTarget
**ppDropTarget
)
1654 wxUnusedVar(pDropTarget
);
1655 wxUnusedVar(ppDropTarget
);
1659 HRESULT wxSTDCALL
DocHostUIHandler::GetExternal(IDispatch
**ppDispatch
)
1661 wxUnusedVar(ppDispatch
);
1665 HRESULT wxSTDCALL
DocHostUIHandler::TranslateUrl(DWORD dwTranslate
,
1667 OLECHAR
**ppchURLOut
)
1669 wxUnusedVar(dwTranslate
);
1670 wxUnusedVar(pchURLIn
);
1671 wxUnusedVar(ppchURLOut
);
1675 HRESULT wxSTDCALL
DocHostUIHandler::FilterDataObject(IDataObject
*pDO
, IDataObject
**ppDORet
)
1678 wxUnusedVar(ppDORet
);
1682 BEGIN_IID_TABLE(DocHostUIHandler
)
1684 ADD_RAW_IID(wxIID_IDocHostUIHandler
)
1687 IMPLEMENT_IUNKNOWN_METHODS(DocHostUIHandler
)
1689 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE