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, 2011 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"
19 #if wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
26 #include "wx/msw/registry.h"
27 #include "wx/msw/missing.h"
28 #include "wx/filesys.h"
29 #include "wx/dynlib.h"
33 /* These GUID definitions are our own implementation to support interfaces
34 * normally in urlmon.h. See include/wx/msw/webview_ie.h
39 DEFINE_GUID(wxIID_IInternetProtocolRoot
,0x79eac9e3,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
40 DEFINE_GUID(wxIID_IInternetProtocol
,0x79eac9e4,0xbaf9,0x11ce,0x8c,0x82,0,0xaa,0,0x4b,0xa9,0xb);
41 DEFINE_GUID(wxIID_IDocHostUIHandler
, 0xbd3f23c0, 0xd43e, 0x11cf, 0x89, 0x3b, 0x00, 0xaa, 0x00, 0xbd, 0xce, 0x1a);
42 DEFINE_GUID(wxIID_IHTMLElement2
,0x3050f434,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
43 DEFINE_GUID(wxIID_IMarkupServices
,0x3050f4a0,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
44 DEFINE_GUID(wxIID_IMarkupContainer
,0x3050f5f9,0x98b5,0x11cf,0xbb,0x82,0,0xaa,0,0xbd,0xce,0x0b);
46 enum //Internal find flags
48 wxWEBVIEW_FIND_ADD_POINTERS
= 0x0001,
49 wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
= 0x0002
54 //Convenience function for error conversion
55 #define WX_ERROR_CASE(error, wxerror) \
57 event.SetString(#error); \
58 event.SetInt(wxerror); \
61 wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewIE
, wxWebView
);
63 BEGIN_EVENT_TABLE(wxWebViewIE
, wxControl
)
64 EVT_ACTIVEX(wxID_ANY
, wxWebViewIE::onActiveXEvent
)
65 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg
)
68 bool wxWebViewIE::Create(wxWindow
* parent
,
76 if (!wxControl::Create(parent
, id
, pos
, size
, style
,
77 wxDefaultValidator
, name
))
84 m_historyLoadingFromList
= false;
85 m_historyEnabled
= true;
86 m_historyPosition
= -1;
87 m_zoomType
= wxWEBVIEW_ZOOM_TYPE_TEXT
;
90 if (::CoCreateInstance(CLSID_WebBrowser
, NULL
,
91 CLSCTX_INPROC_SERVER
, // CLSCTX_INPROC,
92 IID_IWebBrowser2
, (void**)&m_webBrowser
) != 0)
94 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
98 m_ie
.SetDispatchPtr(m_webBrowser
); // wxAutomationObject will release itself
100 m_webBrowser
->put_RegisterAsBrowser(VARIANT_TRUE
);
101 m_webBrowser
->put_RegisterAsDropTarget(VARIANT_TRUE
);
103 m_uiHandler
= new DocHostUIHandler(this);
105 m_container
= new wxIEContainer(this, IID_IWebBrowser2
, m_webBrowser
, m_uiHandler
);
107 EnableControlFeature(21 /* FEATURE_DISABLE_NAVIGATION_SOUNDS */);
113 wxWebViewIE::~wxWebViewIE()
115 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
116 if(urlMon
.HasSymbol(wxT("CoInternetGetSession")))
118 typedef HRESULT (WINAPI
*CoInternetGetSession_t
)(DWORD
,
119 wxIInternetSession
**,
121 wxDYNLIB_FUNCTION(CoInternetGetSession_t
, CoInternetGetSession
, urlMon
);
123 wxIInternetSession
* session
;
124 HRESULT res
= (*pfnCoInternetGetSession
)(0, &session
, 0);
127 wxFAIL_MSG("Could not retrive internet session");
130 for(unsigned int i
= 0; i
< m_factories
.size(); i
++)
132 session
->UnregisterNameSpace(m_factories
[i
],
133 (m_factories
[i
]->GetName()).wc_str());
134 m_factories
[i
]->Release();
140 void wxWebViewIE::LoadURL(const wxString
& url
)
142 m_ie
.CallMethod("Navigate", wxConvertStringToOle(url
));
145 void wxWebViewIE::DoSetPage(const wxString
& html
, const wxString
& baseUrl
)
147 BSTR bstr
= SysAllocString(OLESTR(""));
148 SAFEARRAY
*psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
149 if (psaStrings
!= NULL
)
152 HRESULT hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
154 param
->bstrVal
= bstr
;
156 hr
= SafeArrayUnaccessData(psaStrings
);
158 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
163 document
->write(psaStrings
);
166 SafeArrayDestroy(psaStrings
);
168 bstr
= SysAllocString(html
.wc_str());
170 // Creates a new one-dimensional array
171 psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
172 if (psaStrings
!= NULL
)
174 hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
176 param
->bstrVal
= bstr
;
177 hr
= SafeArrayUnaccessData(psaStrings
);
179 document
= GetDocument();
184 document
->write(psaStrings
);
186 // SafeArrayDestroy calls SysFreeString for each BSTR
187 SafeArrayDestroy(psaStrings
);
189 //We send the events when we are done to mimic webkit
191 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATED
,
192 GetId(), baseUrl
, "");
193 event
.SetEventObject(this);
194 HandleWindowEvent(event
);
196 //Document complete event
197 event
.SetEventType(wxEVT_WEBVIEW_LOADED
);
198 event
.SetEventObject(this);
199 HandleWindowEvent(event
);
203 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
208 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL during clear");
212 wxString
wxWebViewIE::GetPageSource() const
214 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
218 wxCOMPtr
<IHTMLElement
> bodyTag
;
219 wxCOMPtr
<IHTMLElement
> htmlTag
;
221 HRESULT hr
= document
->get_body(&bodyTag
);
224 hr
= bodyTag
->get_parentElement(&htmlTag
);
228 htmlTag
->get_outerHTML(&bstr
);
229 source
= wxString(bstr
);
240 wxWebViewZoom
wxWebViewIE::GetZoom() const
244 case wxWEBVIEW_ZOOM_TYPE_LAYOUT
:
245 return GetIEOpticalZoom();
246 case wxWEBVIEW_ZOOM_TYPE_TEXT
:
247 return GetIETextZoom();
252 //Dummy return to stop compiler warnings
253 return wxWEBVIEW_ZOOM_MEDIUM
;
257 void wxWebViewIE::SetZoom(wxWebViewZoom zoom
)
261 case wxWEBVIEW_ZOOM_TYPE_LAYOUT
:
262 SetIEOpticalZoom(zoom
);
264 case wxWEBVIEW_ZOOM_TYPE_TEXT
:
272 void wxWebViewIE::SetIETextZoom(wxWebViewZoom level
)
274 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
275 //is 0 to 4 so the check is unnecessary, these match exactly with the
278 VariantInit (&zoomVariant
);
279 V_VT(&zoomVariant
) = VT_I4
;
280 V_I4(&zoomVariant
) = level
;
285 m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
286 OLECMDEXECOPT_DONTPROMPTUSER
,
288 wxASSERT(result
== S_OK
);
291 wxWebViewZoom
wxWebViewIE::GetIETextZoom() const
294 VariantInit (&zoomVariant
);
295 V_VT(&zoomVariant
) = VT_I4
;
300 m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
301 OLECMDEXECOPT_DONTPROMPTUSER
,
303 wxASSERT(result
== S_OK
);
305 //We can safely cast here as we know that the range matches our enum
306 return static_cast<wxWebViewZoom
>(V_I4(&zoomVariant
));
309 void wxWebViewIE::SetIEOpticalZoom(wxWebViewZoom level
)
311 //We do not use OLECMDID_OPTICAL_GETZOOMRANGE as the docs say the range
312 //is 10 to 1000 so the check is unnecessary
314 VariantInit (&zoomVariant
);
315 V_VT(&zoomVariant
) = VT_I4
;
317 //We make a somewhat arbitray map here, taken from values used by webkit
320 case wxWEBVIEW_ZOOM_TINY
:
321 V_I4(&zoomVariant
) = 60;
323 case wxWEBVIEW_ZOOM_SMALL
:
324 V_I4(&zoomVariant
) = 80;
326 case wxWEBVIEW_ZOOM_MEDIUM
:
327 V_I4(&zoomVariant
) = 100;
329 case wxWEBVIEW_ZOOM_LARGE
:
330 V_I4(&zoomVariant
) = 130;
332 case wxWEBVIEW_ZOOM_LARGEST
:
333 V_I4(&zoomVariant
) = 160;
342 m_webBrowser
->ExecWB((OLECMDID
)63 /*OLECMDID_OPTICAL_ZOOM*/,
343 OLECMDEXECOPT_DODEFAULT
,
346 wxASSERT(result
== S_OK
);
349 wxWebViewZoom
wxWebViewIE::GetIEOpticalZoom() const
352 VariantInit (&zoomVariant
);
353 V_VT(&zoomVariant
) = VT_I4
;
358 m_webBrowser
->ExecWB((OLECMDID
)63 /*OLECMDID_OPTICAL_ZOOM*/,
359 OLECMDEXECOPT_DODEFAULT
, NULL
,
361 wxASSERT(result
== S_OK
);
363 const int zoom
= V_I4(&zoomVariant
);
365 //We make a somewhat arbitray map here, taken from values used by webkit
368 return wxWEBVIEW_ZOOM_TINY
;
370 else if (zoom
> 65 && zoom
<= 90)
372 return wxWEBVIEW_ZOOM_SMALL
;
374 else if (zoom
> 90 && zoom
<= 115)
376 return wxWEBVIEW_ZOOM_MEDIUM
;
378 else if (zoom
> 115 && zoom
<= 145)
380 return wxWEBVIEW_ZOOM_LARGE
;
382 else /*if (zoom > 145) */ //Using else removes a compiler warning
384 return wxWEBVIEW_ZOOM_LARGEST
;
388 void wxWebViewIE::SetZoomType(wxWebViewZoomType type
)
393 wxWebViewZoomType
wxWebViewIE::GetZoomType() const
398 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType type
) const
400 //IE 6 and below only support text zoom, so check the registry to see what
401 //version we actually have
402 wxRegKey
key(wxRegKey::HKLM
, "Software\\Microsoft\\Internet Explorer");
404 key
.QueryValue("Version", value
);
406 long version
= wxAtoi(value
.Left(1));
407 if(version
<= 6 && type
== wxWEBVIEW_ZOOM_TYPE_LAYOUT
)
413 void wxWebViewIE::Print()
415 m_webBrowser
->ExecWB(OLECMDID_PRINTPREVIEW
,
416 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
419 bool wxWebViewIE::CanGoBack() const
422 return m_historyPosition
> 0;
427 bool wxWebViewIE::CanGoForward() const
430 return m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1;
435 void wxWebViewIE::LoadHistoryItem(wxSharedPtr
<wxWebViewHistoryItem
> item
)
438 for(unsigned int i
= 0; i
< m_historyList
.size(); i
++)
440 //We compare the actual pointers to find the correct item
441 if(m_historyList
[i
].get() == item
.get())
444 wxASSERT_MSG(pos
!= static_cast<int>(m_historyList
.size()),
445 "invalid history item");
446 m_historyLoadingFromList
= true;
447 LoadURL(item
->GetUrl());
448 m_historyPosition
= pos
;
451 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > wxWebViewIE::GetBackwardHistory()
453 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > backhist
;
454 //As we don't have std::copy or an iterator constructor in the wxwidgets
455 //native vector we construct it by hand
456 for(int i
= 0; i
< m_historyPosition
; i
++)
458 backhist
.push_back(m_historyList
[i
]);
463 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > wxWebViewIE::GetForwardHistory()
465 wxVector
<wxSharedPtr
<wxWebViewHistoryItem
> > forwardhist
;
466 //As we don't have std::copy or an iterator constructor in the wxwidgets
467 //native vector we construct it by hand
468 for(int i
= m_historyPosition
+ 1; i
< static_cast<int>(m_historyList
.size()); i
++)
470 forwardhist
.push_back(m_historyList
[i
]);
475 void wxWebViewIE::GoBack()
477 LoadHistoryItem(m_historyList
[m_historyPosition
- 1]);
480 void wxWebViewIE::GoForward()
482 LoadHistoryItem(m_historyList
[m_historyPosition
+ 1]);
485 void wxWebViewIE::Stop()
487 m_ie
.CallMethod("Stop");
490 void wxWebViewIE::ClearHistory()
492 m_historyList
.clear();
493 m_historyPosition
= -1;
496 void wxWebViewIE::EnableHistory(bool enable
)
498 m_historyEnabled
= enable
;
499 m_historyList
.clear();
500 m_historyPosition
= -1;
503 void wxWebViewIE::Reload(wxWebViewReloadFlags flags
)
507 V_VT(&level
) = VT_I2
;
511 case wxWEBVIEW_RELOAD_DEFAULT
:
512 V_I2(&level
) = REFRESH_NORMAL
;
514 case wxWEBVIEW_RELOAD_NO_CACHE
:
515 V_I2(&level
) = REFRESH_COMPLETELY
;
518 wxFAIL_MSG("Unexpected reload type");
521 m_webBrowser
->Refresh2(&level
);
524 bool wxWebViewIE::IsOfflineMode()
526 wxVariant out
= m_ie
.GetProperty("Offline");
528 wxASSERT(out
.GetType() == "bool");
530 return out
.GetBool();
533 void wxWebViewIE::SetOfflineMode(bool offline
)
535 // FIXME: the wxWidgets docs do not really document what the return
536 // parameter of PutProperty is
540 m_ie
.PutProperty("Offline", (offline
?
546 bool wxWebViewIE::IsBusy() const
548 if (m_isBusy
) return true;
550 wxVariant out
= m_ie
.GetProperty("Busy");
552 wxASSERT(out
.GetType() == "bool");
554 return out
.GetBool();
557 wxString
wxWebViewIE::GetCurrentURL() const
559 wxVariant out
= m_ie
.GetProperty("LocationURL");
561 wxASSERT(out
.GetType() == "string");
562 return out
.GetString();
565 wxString
wxWebViewIE::GetCurrentTitle() const
567 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
572 document
->get_nameProp(&title
);
573 return wxString(title
);
581 bool wxWebViewIE::CanCut() const
583 return CanExecCommand("Cut");
586 bool wxWebViewIE::CanCopy() const
588 return CanExecCommand("Copy");
591 bool wxWebViewIE::CanPaste() const
593 return CanExecCommand("Paste");
596 void wxWebViewIE::Cut()
601 void wxWebViewIE::Copy()
606 void wxWebViewIE::Paste()
608 ExecCommand("Paste");
611 bool wxWebViewIE::CanUndo() const
613 return CanExecCommand("Undo");
616 bool wxWebViewIE::CanRedo() const
618 return CanExecCommand("Redo");
621 void wxWebViewIE::Undo()
626 void wxWebViewIE::Redo()
631 long wxWebViewIE::Find(const wxString
& text
, int flags
)
633 //If the text is empty then we clear.
637 if(m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
639 FindInternal(m_findText
, (m_findFlags
&~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT
), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
);
644 //Have we done this search before?
645 if(m_findText
== text
)
647 //Just do a highlight?
648 if((flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
) != (m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
))
651 if(!m_findPointers
.empty())
653 FindInternal(m_findText
, m_findFlags
, ((flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
) == 0 ? wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
: 0));
655 return m_findPosition
;
657 else if(((m_findFlags
& wxWEBVIEW_FIND_ENTIRE_WORD
) == (flags
& wxWEBVIEW_FIND_ENTIRE_WORD
)) && ((m_findFlags
& wxWEBVIEW_FIND_MATCH_CASE
) == (flags
&wxWEBVIEW_FIND_MATCH_CASE
)))
660 return FindNext(((flags
& wxWEBVIEW_FIND_BACKWARDS
) ? -1 : 1));
663 //Remove old highlight if any.
664 if(m_findFlags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
666 FindInternal(m_findText
, (m_findFlags
&~ wxWEBVIEW_FIND_HIGHLIGHT_RESULT
), wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
);
668 //Reset find variables.
673 //find the text and return wxNOT_FOUND if there are no matches.
674 FindInternal(text
, flags
, wxWEBVIEW_FIND_ADD_POINTERS
);
675 if(m_findPointers
.empty())
678 // Or their number if there are.
679 return m_findPointers
.size();
682 void wxWebViewIE::SetEditable(bool enable
)
684 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
689 document
->put_designMode(SysAllocString(L
"On"));
691 document
->put_designMode(SysAllocString(L
"Off"));
696 bool wxWebViewIE::IsEditable() const
698 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
703 document
->get_designMode(&mode
);
704 if(wxString(mode
) == "On")
715 void wxWebViewIE::SelectAll()
717 ExecCommand("SelectAll");
720 bool wxWebViewIE::HasSelection() const
722 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
726 wxCOMPtr
<IHTMLSelectionObject
> selection
;
728 HRESULT hr
= document
->get_selection(&selection
);
732 selection
->get_type(&type
);
733 sel
= wxString(type
);
735 return sel
!= "None";
743 void wxWebViewIE::DeleteSelection()
745 ExecCommand("Delete");
748 wxString
wxWebViewIE::GetSelectedText() const
750 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
754 wxCOMPtr
<IHTMLSelectionObject
> selection
;
756 HRESULT hr
= document
->get_selection(&selection
);
759 wxCOMPtr
<IDispatch
> disrange
;
760 hr
= selection
->createRange(&disrange
);
763 wxCOMPtr
<IHTMLTxtRange
> range
;
764 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
768 range
->get_text(&text
);
769 selected
= wxString(text
);
781 wxString
wxWebViewIE::GetSelectedSource() const
783 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
787 wxCOMPtr
<IHTMLSelectionObject
> selection
;
789 HRESULT hr
= document
->get_selection(&selection
);
792 wxCOMPtr
<IDispatch
> disrange
;
793 hr
= selection
->createRange(&disrange
);
796 wxCOMPtr
<IHTMLTxtRange
> range
;
797 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
801 range
->get_htmlText(&text
);
802 selected
= wxString(text
);
814 void wxWebViewIE::ClearSelection()
816 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
820 wxCOMPtr
<IHTMLSelectionObject
> selection
;
822 HRESULT hr
= document
->get_selection(&selection
);
830 wxString
wxWebViewIE::GetPageText() const
832 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
837 wxCOMPtr
<IHTMLElement
> body
;
838 HRESULT hr
= document
->get_body(&body
);
842 body
->get_innerText(&out
);
843 text
= wxString(out
);
853 void wxWebViewIE::RunScript(const wxString
& javascript
)
855 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
859 wxCOMPtr
<IHTMLWindow2
> window
;
860 wxString language
= "javascript";
861 HRESULT hr
= document
->get_parentWindow(&window
);
866 V_VT(&level
) = VT_EMPTY
;
867 window
->execScript(SysAllocString(javascript
.wc_str()),
868 SysAllocString(language
.wc_str()),
874 void wxWebViewIE::RegisterHandler(wxSharedPtr
<wxWebViewHandler
> handler
)
876 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
877 if(urlMon
.HasSymbol(wxT("CoInternetGetSession")))
879 typedef HRESULT (WINAPI
*CoInternetGetSession_t
)(DWORD
, wxIInternetSession
**, DWORD
);
880 wxDYNLIB_FUNCTION(CoInternetGetSession_t
, CoInternetGetSession
, urlMon
);
882 ClassFactory
* cf
= new ClassFactory(handler
);
883 wxIInternetSession
* session
;
884 HRESULT res
= (*pfnCoInternetGetSession
)(0, &session
, 0);
887 wxFAIL_MSG("Could not retrive internet session");
890 HRESULT hr
= session
->RegisterNameSpace(cf
, CLSID_FileProtocol
,
891 handler
->GetName().wc_str(),
895 wxFAIL_MSG("Could not register protocol");
897 m_factories
.push_back(cf
);
901 wxFAIL_MSG("urlmon does not contain CoInternetGetSession");
905 bool wxWebViewIE::CanExecCommand(wxString command
) const
907 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
911 VARIANT_BOOL enabled
;
913 document
->queryCommandEnabled(SysAllocString(command
.wc_str()), &enabled
);
915 return (enabled
== VARIANT_TRUE
);
924 void wxWebViewIE::ExecCommand(wxString command
)
926 wxCOMPtr
<IHTMLDocument2
> document(GetDocument());
930 document
->execCommand(SysAllocString(command
.wc_str()), VARIANT_FALSE
, VARIANT(), NULL
);
934 wxCOMPtr
<IHTMLDocument2
> wxWebViewIE::GetDocument() const
936 wxCOMPtr
<IDispatch
> dispatch
;
937 wxCOMPtr
<IHTMLDocument2
> document
;
938 HRESULT result
= m_webBrowser
->get_Document(&dispatch
);
939 if(dispatch
&& SUCCEEDED(result
))
941 //document is set to null automatically if the interface isn't supported
942 dispatch
->QueryInterface(IID_IHTMLDocument2
, (void**)&document
);
947 bool wxWebViewIE::IsElementVisible(wxCOMPtr
<IHTMLElement
> elm
)
949 wxCOMPtr
<IHTMLElement
> elm1
= elm
;
951 bool is_visible
= true;
952 //This method is not perfect but it does discover most of the hidden elements.
953 //so if a better solution is found, then please do improve.
956 wxCOMPtr
<wxIHTMLElement2
> elm2
;
957 if(SUCCEEDED(elm1
->QueryInterface(wxIID_IHTMLElement2
, (void**) &elm2
)))
959 wxCOMPtr
<wxIHTMLCurrentStyle
> style
;
960 if(SUCCEEDED(elm2
->get_currentStyle(&style
)))
962 //Check if the object has the style display:none.
963 if((style
->get_display(&tmp_bstr
) != S_OK
) ||
964 (tmp_bstr
!= NULL
&& (_wcsicmp(tmp_bstr
, L
"none") == 0)))
968 //Check if the object has the style visibility:hidden.
969 if((is_visible
&& (style
->get_visibility(&tmp_bstr
) != S_OK
)) ||
970 (tmp_bstr
!= NULL
&& _wcsicmp(tmp_bstr
, L
"hidden") == 0))
979 //Lets check the object's parent element.
980 IHTMLElement
* parent
;
981 if(is_visible
&& SUCCEEDED(elm1
->get_parentElement(&parent
)))
994 void wxWebViewIE::FindInternal(const wxString
& text
, int flags
, int internal_flag
)
997 wxCOMPtr
<wxIMarkupServices
> pIMS
;
998 wxCOMPtr
<IHTMLDocument2
> document
= GetDocument();
1000 //This function does the acutal work.
1001 if(document
&& SUCCEEDED(document
->QueryInterface(wxIID_IMarkupServices
, (void **)&pIMS
)))
1003 wxCOMPtr
<wxIMarkupContainer
> pIMC
;
1004 if(SUCCEEDED(document
->QueryInterface(wxIID_IMarkupContainer
, (void **)&pIMC
)))
1006 wxCOMPtr
<wxIMarkupPointer
> ptrBegin
, ptrEnd
;
1007 BSTR attr_bstr
= SysAllocString(L
"style=\"background-color:#ffff00\"");
1008 BSTR text_bstr
= SysAllocString(text
.wc_str());
1009 pIMS
->CreateMarkupPointer(&ptrBegin
);
1010 pIMS
->CreateMarkupPointer(&ptrEnd
);
1012 ptrBegin
->SetGravity(wxPOINTER_GRAVITY_Right
);
1013 ptrBegin
->MoveToContainer(pIMC
, TRUE
);
1014 //Create the find flag from the wx one.
1015 if(flags
& wxWEBVIEW_FIND_ENTIRE_WORD
)
1017 find_flag
|= wxFINDTEXT_WHOLEWORD
;
1019 if(flags
& wxWEBVIEW_FIND_MATCH_CASE
)
1021 find_flag
|= wxFINDTEXT_MATCHCASE
;
1024 //A little speed-up to avoid to re-alloc in the positions vector.
1025 if(text
.Len() < 3 && m_findPointers
.capacity() < 500)
1027 m_findPointers
.reserve(text
.Len() == 1 ? 1000 : 500);
1030 while(ptrBegin
->FindText(text_bstr
, find_flag
, ptrEnd
, NULL
) == S_OK
)
1032 wxCOMPtr
<IHTMLElement
> elm
;
1033 if(ptrBegin
->CurrentScope(&elm
) == S_OK
)
1035 if(IsElementVisible(elm
))
1037 //Highlight the word if the flag was set.
1038 if(flags
& wxWEBVIEW_FIND_HIGHLIGHT_RESULT
)
1040 IHTMLElement
* pFontEl
;
1041 pIMS
->CreateElement(wxTAGID_FONT
, attr_bstr
, &pFontEl
);
1042 pIMS
->InsertElement(pFontEl
, ptrBegin
, ptrEnd
);
1044 if(internal_flag
& wxWEBVIEW_FIND_REMOVE_HIGHLIGHT
)
1046 IHTMLElement
* pFontEl
;
1047 ptrBegin
->CurrentScope(&pFontEl
);
1048 pIMS
->RemoveElement(pFontEl
);
1051 if(internal_flag
& wxWEBVIEW_FIND_ADD_POINTERS
)
1053 wxIMarkupPointer
*cptrBegin
, *cptrEnd
;
1054 pIMS
->CreateMarkupPointer(&cptrBegin
);
1055 pIMS
->CreateMarkupPointer(&cptrEnd
);
1056 cptrBegin
->MoveToPointer(ptrBegin
);
1057 cptrEnd
->MoveToPointer(ptrEnd
);
1058 m_findPointers
.push_back(wxFindPointers(cptrBegin
,cptrEnd
));
1062 ptrBegin
->MoveToPointer(ptrEnd
);
1065 SysFreeString(text_bstr
);
1066 SysFreeString(attr_bstr
);
1071 long wxWebViewIE::FindNext(int direction
)
1073 //Don't bother if we have no pointers set.
1074 if(m_findPointers
.empty())
1078 //Manage the find position and do some checks.
1088 if(m_findPosition
>= (signed)m_findPointers
.size())
1090 if(m_findFlags
& wxWEBVIEW_FIND_WRAP
)
1100 else if(m_findPosition
< 0)
1102 if(m_findFlags
& wxWEBVIEW_FIND_WRAP
)
1104 m_findPosition
= m_findPointers
.size()-1;
1113 wxCOMPtr
<IHTMLDocument2
> document
= GetDocument();
1114 wxCOMPtr
<IHTMLElement
> body_element
;
1117 //Now try to create a range from the body.
1118 if(document
&& SUCCEEDED(document
->get_body(&body_element
)))
1120 wxCOMPtr
<IHTMLBodyElement
> body
;
1121 if(SUCCEEDED(body_element
->QueryInterface(IID_IHTMLBodyElement
,(void**)&body
)))
1123 wxCOMPtr
<wxIHTMLTxtRange
> range
;
1124 if(SUCCEEDED(body
->createTextRange((IHTMLTxtRange
**)(&range
))))
1126 wxCOMPtr
<wxIMarkupServices
> pIMS
;
1127 //So far so good, now we try to position our find pointers.
1128 if(SUCCEEDED(document
->QueryInterface(wxIID_IMarkupServices
,(void **)&pIMS
)))
1130 wxIMarkupPointer
*begin
= m_findPointers
[m_findPosition
].begin
, *end
= m_findPointers
[m_findPosition
].end
;
1131 if(pIMS
->MoveRangeToPointers(begin
,end
,range
) == S_OK
&& range
->select() == S_OK
)
1133 ret
= m_findPosition
;
1142 void wxWebViewIE::FindClear()
1144 //Reset find variables.
1146 m_findFlags
= wxWEBVIEW_FIND_DEFAULT
;
1147 m_findPosition
= -1;
1149 //The m_findPointers contains pointers for the found text.
1150 //Since it uses ref counting we call release on the pointers first
1151 //before we remove them from the vector. In other words do not just
1152 //remove elements from m_findPointers without calling release first
1153 //or you will get a memory leak.
1154 size_t count
= m_findPointers
.size();
1155 for(size_t i
= 0; i
< count
; i
++)
1157 m_findPointers
[i
].begin
->Release();
1158 m_findPointers
[i
].end
->Release();
1160 m_findPointers
.clear();
1163 bool wxWebViewIE::EnableControlFeature(long flag
, bool enable
)
1165 #if wxUSE_DYNLIB_CLASS
1167 wxDynamicLibrary
urlMon(wxT("urlmon.dll"));
1168 if( urlMon
.IsLoaded() &&
1169 urlMon
.HasSymbol("CoInternetSetFeatureEnabled") &&
1170 urlMon
.HasSymbol("CoInternetIsFeatureEnabled"))
1172 typedef HRESULT (WINAPI
*CoInternetSetFeatureEnabled_t
)(DWORD
, DWORD
, BOOL
);
1173 typedef HRESULT (WINAPI
*CoInternetIsFeatureEnabled_t
)(DWORD
, DWORD
);
1175 wxDYNLIB_FUNCTION(CoInternetSetFeatureEnabled_t
, CoInternetSetFeatureEnabled
, urlMon
);
1176 wxDYNLIB_FUNCTION(CoInternetIsFeatureEnabled_t
, CoInternetIsFeatureEnabled
, urlMon
);
1178 HRESULT hr
= (*pfnCoInternetIsFeatureEnabled
)(flag
,
1179 0x2 /* SET_FEATURE_ON_PROCESS */);
1180 if((hr
== S_OK
&& enable
) || (hr
== S_FALSE
&& !enable
))
1183 hr
= (*pfnCoInternetSetFeatureEnabled
)(flag
,
1184 0x2/* SET_FEATURE_ON_PROCESS */,
1185 (enable
? TRUE
: FALSE
));
1188 wxLogApiError(wxT("CoInternetSetFeatureEnabled"), hr
);
1196 wxUnusedVar(enable
);
1198 #endif // wxUSE_DYNLIB_CLASS/!wxUSE_DYNLIB_CLASS
1201 void wxWebViewIE::onActiveXEvent(wxActiveXEvent
& evt
)
1203 if (m_webBrowser
== NULL
) return;
1205 switch (evt
.GetDispatchId())
1207 case DISPID_BEFORENAVIGATE2
:
1211 wxString url
= evt
[1].GetString();
1212 wxString target
= evt
[3].GetString();
1214 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATING
,
1215 GetId(), url
, target
);
1217 //skip empty javascript events.
1218 if(url
== "javascript:\"\"" && target
.IsEmpty())
1224 event
.SetEventObject(this);
1225 HandleWindowEvent(event
);
1228 if (!event
.IsAllowed())
1230 wxActiveXEventNativeMSW
* nativeParams
=
1231 evt
.GetNativeParameters();
1232 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[0]) = VARIANT_TRUE
;
1235 // at this point, either the navigation event has been cancelled
1236 // and we're not busy, either it was accepted and IWebBrowser2's
1237 // Busy property will be true; so we don't need our override
1244 case DISPID_NAVIGATECOMPLETE2
:
1246 wxString url
= evt
[1].GetString();
1247 // TODO: set target parameter if possible
1248 wxString target
= wxEmptyString
;
1249 wxWebViewEvent
event(wxEVT_WEBVIEW_NAVIGATED
,
1250 GetId(), url
, target
);
1251 event
.SetEventObject(this);
1252 HandleWindowEvent(event
);
1256 case DISPID_PROGRESSCHANGE
:
1258 // download progress
1262 case DISPID_DOCUMENTCOMPLETE
:
1264 //Only send a complete even if we are actually finished, this brings
1265 //the event in to line with webkit
1267 m_webBrowser
->get_ReadyState( &rs
);
1268 if(rs
!= READYSTATE_COMPLETE
)
1271 wxString url
= evt
[1].GetString();
1273 //As we are complete we also add to the history list, but not if the
1274 //page is not the main page, ie it is a subframe
1275 //We also have to check if we are loading a file:// url, if so we
1276 //need to change the comparison as ie passes back a different style
1278 if(m_historyEnabled
&& !m_historyLoadingFromList
&&
1279 (url
== GetCurrentURL() ||
1280 (GetCurrentURL().substr(0, 4) == "file" &&
1281 wxFileSystem::URLToFileName(GetCurrentURL()).GetFullPath() == url
)))
1283 //If we are not at the end of the list, then erase everything
1284 //between us and the end before adding the new page
1285 if(m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1)
1287 m_historyList
.erase(m_historyList
.begin() + m_historyPosition
+ 1,
1288 m_historyList
.end());
1290 wxSharedPtr
<wxWebViewHistoryItem
> item(new wxWebViewHistoryItem(url
, GetCurrentTitle()));
1291 m_historyList
.push_back(item
);
1292 m_historyPosition
++;
1294 //Reset as we are done now
1295 m_historyLoadingFromList
= false;
1296 //Reset the find values.
1298 // TODO: set target parameter if possible
1299 wxString target
= wxEmptyString
;
1300 wxWebViewEvent
event(wxEVT_WEBVIEW_LOADED
, GetId(),
1302 event
.SetEventObject(this);
1303 HandleWindowEvent(event
);
1307 case DISPID_STATUSTEXTCHANGE
:
1312 case DISPID_TITLECHANGE
:
1314 wxString title
= evt
[0].GetString();
1316 wxWebViewEvent
event(wxEVT_WEBVIEW_TITLE_CHANGED
,
1317 GetId(), GetCurrentURL(), "");
1318 event
.SetString(title
);
1319 event
.SetEventObject(this);
1320 HandleWindowEvent(event
);
1324 case DISPID_NAVIGATEERROR
:
1326 wxWebViewEvent
event(wxEVT_WEBVIEW_ERROR
, GetId(),
1327 evt
[1].GetString(), evt
[2].GetString());
1328 event
.SetEventObject(this);
1330 switch (evt
[3].GetLong())
1333 WX_ERROR_CASE(HTTP_STATUS_BAD_REQUEST
, wxWEBVIEW_NAV_ERR_REQUEST
)
1334 WX_ERROR_CASE(HTTP_STATUS_DENIED
, wxWEBVIEW_NAV_ERR_AUTH
)
1335 WX_ERROR_CASE(HTTP_STATUS_PAYMENT_REQ
, wxWEBVIEW_NAV_ERR_OTHER
)
1336 WX_ERROR_CASE(HTTP_STATUS_FORBIDDEN
, wxWEBVIEW_NAV_ERR_AUTH
)
1337 WX_ERROR_CASE(HTTP_STATUS_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1338 WX_ERROR_CASE(HTTP_STATUS_BAD_METHOD
, wxWEBVIEW_NAV_ERR_REQUEST
)
1339 WX_ERROR_CASE(HTTP_STATUS_NONE_ACCEPTABLE
, wxWEBVIEW_NAV_ERR_OTHER
)
1340 WX_ERROR_CASE(HTTP_STATUS_PROXY_AUTH_REQ
, wxWEBVIEW_NAV_ERR_AUTH
)
1341 WX_ERROR_CASE(HTTP_STATUS_REQUEST_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1342 WX_ERROR_CASE(HTTP_STATUS_CONFLICT
, wxWEBVIEW_NAV_ERR_REQUEST
)
1343 WX_ERROR_CASE(HTTP_STATUS_GONE
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1344 WX_ERROR_CASE(HTTP_STATUS_LENGTH_REQUIRED
, wxWEBVIEW_NAV_ERR_REQUEST
)
1345 WX_ERROR_CASE(HTTP_STATUS_PRECOND_FAILED
, wxWEBVIEW_NAV_ERR_REQUEST
)
1346 WX_ERROR_CASE(HTTP_STATUS_REQUEST_TOO_LARGE
, wxWEBVIEW_NAV_ERR_REQUEST
)
1347 WX_ERROR_CASE(HTTP_STATUS_URI_TOO_LONG
, wxWEBVIEW_NAV_ERR_REQUEST
)
1348 WX_ERROR_CASE(HTTP_STATUS_UNSUPPORTED_MEDIA
, wxWEBVIEW_NAV_ERR_REQUEST
)
1349 WX_ERROR_CASE(HTTP_STATUS_RETRY_WITH
, wxWEBVIEW_NAV_ERR_OTHER
)
1351 // 500 - Error codes
1352 WX_ERROR_CASE(HTTP_STATUS_SERVER_ERROR
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1353 WX_ERROR_CASE(HTTP_STATUS_NOT_SUPPORTED
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1354 WX_ERROR_CASE(HTTP_STATUS_BAD_GATEWAY
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1355 WX_ERROR_CASE(HTTP_STATUS_SERVICE_UNAVAIL
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1356 WX_ERROR_CASE(HTTP_STATUS_GATEWAY_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1357 WX_ERROR_CASE(HTTP_STATUS_VERSION_NOT_SUP
, wxWEBVIEW_NAV_ERR_REQUEST
)
1359 // URL Moniker error codes
1360 WX_ERROR_CASE(INET_E_INVALID_URL
, wxWEBVIEW_NAV_ERR_REQUEST
)
1361 WX_ERROR_CASE(INET_E_NO_SESSION
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1362 WX_ERROR_CASE(INET_E_CANNOT_CONNECT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1363 WX_ERROR_CASE(INET_E_RESOURCE_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1364 WX_ERROR_CASE(INET_E_OBJECT_NOT_FOUND
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1365 WX_ERROR_CASE(INET_E_DATA_NOT_AVAILABLE
, wxWEBVIEW_NAV_ERR_NOT_FOUND
)
1366 WX_ERROR_CASE(INET_E_DOWNLOAD_FAILURE
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1367 WX_ERROR_CASE(INET_E_AUTHENTICATION_REQUIRED
, wxWEBVIEW_NAV_ERR_AUTH
)
1368 WX_ERROR_CASE(INET_E_NO_VALID_MEDIA
, wxWEBVIEW_NAV_ERR_REQUEST
)
1369 WX_ERROR_CASE(INET_E_CONNECTION_TIMEOUT
, wxWEBVIEW_NAV_ERR_CONNECTION
)
1370 WX_ERROR_CASE(INET_E_INVALID_REQUEST
, wxWEBVIEW_NAV_ERR_REQUEST
)
1371 WX_ERROR_CASE(INET_E_UNKNOWN_PROTOCOL
, wxWEBVIEW_NAV_ERR_REQUEST
)
1372 WX_ERROR_CASE(INET_E_SECURITY_PROBLEM
, wxWEBVIEW_NAV_ERR_SECURITY
)
1373 WX_ERROR_CASE(INET_E_CANNOT_LOAD_DATA
, wxWEBVIEW_NAV_ERR_OTHER
)
1374 WX_ERROR_CASE(INET_E_REDIRECT_FAILED
, wxWEBVIEW_NAV_ERR_OTHER
)
1375 WX_ERROR_CASE(INET_E_REDIRECT_TO_DIR
, wxWEBVIEW_NAV_ERR_REQUEST
)
1376 WX_ERROR_CASE(INET_E_CANNOT_LOCK_REQUEST
, wxWEBVIEW_NAV_ERR_OTHER
)
1377 WX_ERROR_CASE(INET_E_USE_EXTEND_BINDING
, wxWEBVIEW_NAV_ERR_OTHER
)
1378 WX_ERROR_CASE(INET_E_TERMINATED_BIND
, wxWEBVIEW_NAV_ERR_OTHER
)
1379 WX_ERROR_CASE(INET_E_INVALID_CERTIFICATE
, wxWEBVIEW_NAV_ERR_CERTIFICATE
)
1380 WX_ERROR_CASE(INET_E_CODE_DOWNLOAD_DECLINED
, wxWEBVIEW_NAV_ERR_USER_CANCELLED
)
1381 WX_ERROR_CASE(INET_E_RESULT_DISPATCHED
, wxWEBVIEW_NAV_ERR_OTHER
)
1382 WX_ERROR_CASE(INET_E_CANNOT_REPLACE_SFP_FILE
, wxWEBVIEW_NAV_ERR_SECURITY
)
1383 WX_ERROR_CASE(INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY
, wxWEBVIEW_NAV_ERR_SECURITY
)
1384 WX_ERROR_CASE(INET_E_CODE_INSTALL_SUPPRESSED
, wxWEBVIEW_NAV_ERR_SECURITY
)
1386 HandleWindowEvent(event
);
1389 case DISPID_NEWWINDOW3
:
1391 wxString url
= evt
[4].GetString();
1393 wxWebViewEvent
event(wxEVT_WEBVIEW_NEWWINDOW
,
1394 GetId(), url
, wxEmptyString
);
1395 event
.SetEventObject(this);
1396 HandleWindowEvent(event
);
1398 //We always cancel this event otherwise an Internet Exporer window
1399 //is opened for the url
1400 wxActiveXEventNativeMSW
* nativeParams
= evt
.GetNativeParameters();
1401 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[3]) = VARIANT_TRUE
;
1409 VirtualProtocol::VirtualProtocol(wxSharedPtr
<wxWebViewHandler
> handler
)
1412 m_handler
= handler
;
1415 BEGIN_IID_TABLE(VirtualProtocol
)
1417 ADD_RAW_IID(wxIID_IInternetProtocolRoot
)
1418 ADD_RAW_IID(wxIID_IInternetProtocol
)
1421 IMPLEMENT_IUNKNOWN_METHODS(VirtualProtocol
)
1423 HRESULT STDMETHODCALLTYPE
VirtualProtocol::Start(LPCWSTR szUrl
, wxIInternetProtocolSink
*pOIProtSink
,
1424 wxIInternetBindInfo
*pOIBindInfo
, DWORD grfPI
,
1425 HANDLE_PTR dwReserved
)
1428 wxUnusedVar(pOIBindInfo
);
1430 wxUnusedVar(dwReserved
);
1431 m_protocolSink
= pOIProtSink
;
1433 //We get the file itself from the protocol handler
1434 m_file
= m_handler
->GetFile(szUrl
);
1438 return INET_E_RESOURCE_NOT_FOUND
;
1440 //We return the stream length for current and total size as we can always
1441 //read the whole file from the stream
1442 wxFileOffset length
= m_file
->GetStream()->GetLength();
1443 m_protocolSink
->ReportData(wxBSCF_FIRSTDATANOTIFICATION
|
1444 wxBSCF_DATAFULLYAVAILABLE
|
1445 wxBSCF_LASTDATANOTIFICATION
,
1450 HRESULT STDMETHODCALLTYPE
VirtualProtocol::Read(void *pv
, ULONG cb
, ULONG
*pcbRead
)
1452 //If the file is null we return false to indicte it is finished
1456 wxStreamError err
= m_file
->GetStream()->Read(pv
, cb
).GetLastError();
1457 *pcbRead
= m_file
->GetStream()->LastRead();
1459 if(err
== wxSTREAM_NO_ERROR
)
1464 m_protocolSink
->ReportResult(S_OK
, 0, NULL
);
1466 //As we are not eof there is more data
1469 else if(err
== wxSTREAM_EOF
)
1472 m_protocolSink
->ReportResult(S_OK
, 0, NULL
);
1473 //We are eof and so finished
1476 else if(err
== wxSTREAM_READ_ERROR
)
1479 return INET_E_DOWNLOAD_FAILURE
;
1483 //Dummy return to suppress a compiler warning
1485 return INET_E_DOWNLOAD_FAILURE
;
1489 BEGIN_IID_TABLE(ClassFactory
)
1491 ADD_IID(ClassFactory
)
1494 IMPLEMENT_IUNKNOWN_METHODS(ClassFactory
)
1496 HRESULT STDMETHODCALLTYPE
ClassFactory::CreateInstance(IUnknown
* pUnkOuter
, REFIID riid
,
1500 return CLASS_E_NOAGGREGATION
;
1501 VirtualProtocol
* vp
= new VirtualProtocol(m_handler
);
1503 HRESULT hr
= vp
->QueryInterface(riid
, ppvObject
);
1509 STDMETHODIMP
ClassFactory::LockServer(BOOL fLock
)
1515 wxIEContainer::wxIEContainer(wxWindow
*parent
, REFIID iid
, IUnknown
*pUnk
,
1516 DocHostUIHandler
* uiHandler
) :
1517 wxActiveXContainer(parent
,iid
,pUnk
)
1519 m_uiHandler
= uiHandler
;
1522 wxIEContainer::~wxIEContainer()
1526 bool wxIEContainer::QueryClientSiteInterface(REFIID iid
, void **_interface
,
1529 if (m_uiHandler
&& IsEqualIID(iid
, wxIID_IDocHostUIHandler
))
1531 *_interface
= (IUnknown
*) (wxIDocHostUIHandler
*) m_uiHandler
;
1532 desc
= "IDocHostUIHandler";
1538 HRESULT wxSTDCALL
DocHostUIHandler::ShowContextMenu(DWORD dwID
, POINT
*ppt
,
1539 IUnknown
*pcmdtReserved
,
1540 IDispatch
*pdispReserved
)
1544 wxUnusedVar(pcmdtReserved
);
1545 wxUnusedVar(pdispReserved
);
1546 if(m_browser
->IsContextMenuEnabled())
1552 HRESULT wxSTDCALL
DocHostUIHandler::GetHostInfo(DOCHOSTUIINFO
*pInfo
)
1554 //don't show 3d border and enable themes.
1555 pInfo
->dwFlags
= pInfo
->dwFlags
| DOCHOSTUIFLAG_NO3DBORDER
| DOCHOSTUIFLAG_THEME
;
1559 HRESULT wxSTDCALL
DocHostUIHandler::ShowUI(DWORD dwID
,
1560 IOleInPlaceActiveObject
*pActiveObject
,
1561 IOleCommandTarget
*pCommandTarget
,
1562 IOleInPlaceFrame
*pFrame
,
1563 IOleInPlaceUIWindow
*pDoc
)
1566 wxUnusedVar(pActiveObject
);
1567 wxUnusedVar(pCommandTarget
);
1568 wxUnusedVar(pFrame
);
1573 HRESULT wxSTDCALL
DocHostUIHandler::HideUI(void)
1578 HRESULT wxSTDCALL
DocHostUIHandler::UpdateUI(void)
1583 HRESULT wxSTDCALL
DocHostUIHandler::EnableModeless(BOOL fEnable
)
1585 wxUnusedVar(fEnable
);
1589 HRESULT wxSTDCALL
DocHostUIHandler::OnDocWindowActivate(BOOL fActivate
)
1591 wxUnusedVar(fActivate
);
1595 HRESULT wxSTDCALL
DocHostUIHandler::OnFrameWindowActivate(BOOL fActivate
)
1597 wxUnusedVar(fActivate
);
1601 HRESULT wxSTDCALL
DocHostUIHandler::ResizeBorder(LPCRECT prcBorder
,
1602 IOleInPlaceUIWindow
*pUIWindow
,
1605 wxUnusedVar(prcBorder
);
1606 wxUnusedVar(pUIWindow
);
1607 wxUnusedVar(fFrameWindow
);
1611 HRESULT wxSTDCALL
DocHostUIHandler::TranslateAccelerator(LPMSG lpMsg
,
1612 const GUID
*pguidCmdGroup
,
1615 if(lpMsg
&& lpMsg
->message
== WM_KEYDOWN
)
1617 // check control is down but that it isn't right-alt which is mapped to
1619 if(GetKeyState(VK_CONTROL
) & 0x8000 &&
1620 !(GetKeyState(VK_MENU
) & 0x8000))
1622 //skip the accelerators used by the control
1623 switch(lpMsg
->wParam
)
1634 if(lpMsg
->wParam
== VK_F5
)
1640 wxUnusedVar(pguidCmdGroup
);
1641 wxUnusedVar(nCmdID
);
1645 HRESULT wxSTDCALL
DocHostUIHandler::GetOptionKeyPath(LPOLESTR
*pchKey
,DWORD dw
)
1647 wxUnusedVar(pchKey
);
1652 HRESULT wxSTDCALL
DocHostUIHandler::GetDropTarget(IDropTarget
*pDropTarget
,
1653 IDropTarget
**ppDropTarget
)
1655 wxUnusedVar(pDropTarget
);
1656 wxUnusedVar(ppDropTarget
);
1660 HRESULT wxSTDCALL
DocHostUIHandler::GetExternal(IDispatch
**ppDispatch
)
1662 wxUnusedVar(ppDispatch
);
1666 HRESULT wxSTDCALL
DocHostUIHandler::TranslateUrl(DWORD dwTranslate
,
1668 OLECHAR
**ppchURLOut
)
1670 wxUnusedVar(dwTranslate
);
1671 wxUnusedVar(pchURLIn
);
1672 wxUnusedVar(ppchURLOut
);
1676 HRESULT wxSTDCALL
DocHostUIHandler::FilterDataObject(IDataObject
*pDO
, IDataObject
**ppDORet
)
1679 wxUnusedVar(ppDORet
);
1683 BEGIN_IID_TABLE(DocHostUIHandler
)
1685 ADD_RAW_IID(wxIID_IDocHostUIHandler
)
1688 IMPLEMENT_IUNKNOWN_METHODS(DocHostUIHandler
)
1690 #endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE