// FIXME: calling wxYield is not elegant nor very reliable probably
wxYield();
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
-
- wxASSERT (documentPtr != NULL);
-
// TODO: consider the "baseUrl" parameter if possible
// TODO: consider encoding
BSTR bstr = SysAllocString(html.wc_str());
param->bstrVal = bstr;
hr = SafeArrayUnaccessData(psaStrings);
-
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+ IHTMLDocument2* document = GetDocument();
document->write(psaStrings);
// SafeArrayDestroy calls SysFreeString for each BSTR
wxString wxWebViewIE::GetPageSource()
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
-
- if (documentPtr == NULL)
- {
- return wxEmptyString;
- }
-
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
+ IHTMLDocument2* document = GetDocument();
IHTMLElement *bodyTag = NULL;
IHTMLElement *htmlTag = NULL;
document->get_body(&bodyTag);
wxString wxWebViewIE::GetCurrentTitle()
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
- wxASSERT(documentPtr && document);
+ IHTMLDocument2* document = GetDocument();
BSTR title;
document->get_nameProp(&title);
bool wxWebViewIE::CanExecCommand(wxString command)
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
-
- wxASSERT(documentPtr && document);
+ IHTMLDocument2* document = GetDocument();
VARIANT_BOOL enabled;
document->queryCommandEnabled(SysAllocString(command.wc_str()), &enabled);
void wxWebViewIE::ExecCommand(wxString command)
{
- wxVariant documentVariant = m_ie.GetProperty("Document");
- void* documentPtr = documentVariant.GetVoidPtr();
- IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
+ IHTMLDocument2* document = GetDocument();
+ document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+}
- wxASSERT(documentPtr && document);
+IHTMLDocument2* wxWebViewIE::GetDocument()
+{
+ wxVariant variant = m_ie.GetProperty("Document");
+ IHTMLDocument2* document = (IHTMLDocument2*)variant.GetVoidPtr();
- document->execCommand(SysAllocString(command.wc_str()), VARIANT_FALSE, VARIANT(), NULL);
+ wxASSERT(document);
+
+ return document;
}
void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)