]> git.saurik.com Git - wxWidgets.git/blob - src/msw/webviewie.cpp
Set the correct svn properties on the new files. Correct a minor date typo.
[wxWidgets.git] / src / msw / webviewie.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/webviewie.cpp
3 // Purpose: wxMSW wxWebViewIE class implementation for web view component
4 // Author: Marianne Gagnon
5 // Id: $Id$
6 // Copyright: (c) 2010 Marianne Gagnon
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/msw/webview.h"
11
12 #if wxHAVE_WEB_BACKEND_IE
13
14 #include <olectl.h>
15 #include <oleidl.h>
16 #include <exdispid.h>
17 #include <exdisp.h>
18 #include <mshtml.h>
19
20 // FIXME: Seems like MINGW does not have these, how to handle cleanly?
21 #define DISPID_COMMANDSTATECHANGE 105
22 typedef enum CommandStateChangeConstants {
23 CSC_UPDATECOMMANDS = (int) 0xFFFFFFFF,
24 CSC_NAVIGATEFORWARD = 0x1,
25 CSC_NAVIGATEBACK = 0x2
26 } CommandStateChangeConstants;
27
28
29 // FIXME: Seems like MINGW does not have these, how to handle cleanly?
30 #define DISPID_NAVIGATECOMPLETE2 252
31 #define DISPID_NAVIGATEERROR 271
32 #define OLECMDID_OPTICAL_ZOOM 63
33 #define INET_E_ERROR_FIRST 0x800C0002L
34 #define INET_E_INVALID_URL 0x800C0002L
35 #define INET_E_NO_SESSION 0x800C0003L
36 #define INET_E_CANNOT_CONNECT 0x800C0004L
37 #define INET_E_RESOURCE_NOT_FOUND 0x800C0005L
38 #define INET_E_OBJECT_NOT_FOUND 0x800C0006L
39 #define INET_E_DATA_NOT_AVAILABLE 0x800C0007L
40 #define INET_E_DOWNLOAD_FAILURE 0x800C0008L
41 #define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L
42 #define INET_E_NO_VALID_MEDIA 0x800C000AL
43 #define INET_E_CONNECTION_TIMEOUT 0x800C000BL
44 #define INET_E_INVALID_REQUEST 0x800C000CL
45 #define INET_E_UNKNOWN_PROTOCOL 0x800C000DL
46 #define INET_E_SECURITY_PROBLEM 0x800C000EL
47 #define INET_E_CANNOT_LOAD_DATA 0x800C000FL
48 #define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L
49 #define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L
50 #define INET_E_REDIRECT_FAILED 0x800C0014L
51 #define INET_E_REDIRECT_TO_DIR 0x800C0015L
52 #define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L
53 #define INET_E_USE_EXTEND_BINDING 0x800C0017L
54 #define INET_E_TERMINATED_BIND 0x800C0018L
55 #define INET_E_INVALID_CERTIFICATE 0x800C0019L
56 #define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L
57 #define INET_E_RESULT_DISPATCHED 0x800C0200L
58 #define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L
59 #define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L
60 #define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L
61
62 #define REFRESH_COMPLETELY 3
63
64 BEGIN_EVENT_TABLE(wxWebViewIE, wxControl)
65 EVT_ACTIVEX(wxID_ANY, wxWebViewIE::onActiveXEvent)
66 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg)
67 END_EVENT_TABLE()
68
69 bool wxWebViewIE::Create(wxWindow* parent,
70 wxWindowID id,
71 const wxString& url,
72 const wxPoint& pos,
73 const wxSize& size,
74 long style,
75 const wxString& name)
76 {
77 if (!wxControl::Create(parent, id, pos, size, style,
78 wxDefaultValidator, name))
79 {
80 return false;
81 }
82
83 m_webBrowser = NULL;
84 m_canNavigateBack = false;
85 m_canNavigateForward = false;
86 m_isBusy = false;
87
88 if (::CoCreateInstance(CLSID_WebBrowser, NULL,
89 CLSCTX_INPROC_SERVER, // CLSCTX_INPROC,
90 IID_IWebBrowser2 , (void**)&m_webBrowser) != 0)
91 {
92 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
93 return false;
94 }
95
96 m_ie.SetDispatchPtr(m_webBrowser); // wxAutomationObject will release itself
97
98 m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
99 m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
100 //m_webBrowser->put_Silent(VARIANT_FALSE);
101
102 m_container = new wxActiveXContainer(this, IID_IWebBrowser2, m_webBrowser);
103
104 SetBackgroundStyle(wxBG_STYLE_PAINT);
105 SetDoubleBuffered(true);
106 return true;
107 }
108
109
110 void wxWebViewIE::LoadUrl(const wxString& url)
111 {
112 wxVariant out = m_ie.CallMethod("Navigate", (BSTR) url.wc_str(),
113 NULL, NULL, NULL, NULL);
114
115 // FIXME: why is out value null??
116 //(HRESULT)(out.GetLong()) == S_OK;
117 }
118
119 void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
120 {
121 LoadUrl("about:blank");
122
123 // Let the wx events generated for navigation events be processed, so
124 // that the underlying IE component completes its Document object.
125 // FIXME: calling wxYield is not elegant nor very reliable probably
126 wxYield();
127
128 wxVariant documentVariant = m_ie.GetProperty("Document");
129 void* documentPtr = documentVariant.GetVoidPtr();
130
131 wxASSERT (documentPtr != NULL);
132
133 // TODO: consider the "baseUrl" parameter if possible
134 // TODO: consider encoding
135 BSTR bstr = SysAllocString(html.wc_str());
136
137 // Creates a new one-dimensional array
138 SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
139 if (psaStrings != NULL)
140 {
141 VARIANT *param;
142 HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
143 param->vt = VT_BSTR;
144 param->bstrVal = bstr;
145
146 hr = SafeArrayUnaccessData(psaStrings);
147
148 IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
149 document->write(psaStrings);
150
151 // SafeArrayDestroy calls SysFreeString for each BSTR
152 SafeArrayDestroy(psaStrings);
153 }
154 else
155 {
156 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
157 }
158
159 }
160
161 wxString wxWebViewIE::GetPageSource()
162 {
163 wxVariant documentVariant = m_ie.GetProperty("Document");
164 void* documentPtr = documentVariant.GetVoidPtr();
165
166 if (documentPtr == NULL)
167 {
168 return wxEmptyString;
169 }
170
171 IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
172
173 IHTMLElement *bodyTag = NULL;
174 IHTMLElement *htmlTag = NULL;
175 document->get_body(&bodyTag);
176 wxASSERT(bodyTag != NULL);
177
178 document->Release();
179 bodyTag->get_parentElement(&htmlTag);
180 wxASSERT(htmlTag != NULL);
181
182 BSTR bstr;
183 htmlTag->get_outerHTML(&bstr);
184
185 bodyTag->Release();
186 htmlTag->Release();
187
188 //wxMessageBox(wxString(bstr));
189
190 // TODO: check encoding
191 return wxString(bstr);
192 }
193
194 // FIXME? retrieve OLECMDID_GETZOOMRANGE instead of hardcoding range 0-4
195 wxWebViewZoom wxWebViewIE::GetZoom()
196 {
197 const int zoom = GetIETextZoom();
198
199 switch (zoom)
200 {
201 case 0:
202 return wxWEB_VIEW_ZOOM_TINY;
203 break;
204 case 1:
205 return wxWEB_VIEW_ZOOM_SMALL;
206 break;
207 case 2:
208 return wxWEB_VIEW_ZOOM_MEDIUM;
209 break;
210 case 3:
211 return wxWEB_VIEW_ZOOM_LARGE;
212 break;
213 case 4:
214 return wxWEB_VIEW_ZOOM_LARGEST;
215 break;
216 default:
217 wxASSERT(false);
218 return wxWEB_VIEW_ZOOM_MEDIUM;
219 }
220 }
221 void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
222 {
223 // I know I could cast from enum to int since wxWebViewZoom happens to
224 // match with IE's zoom levels, but I don't like doing that, what if enum
225 // values change...
226 switch (zoom)
227 {
228 case wxWEB_VIEW_ZOOM_TINY:
229 SetIETextZoom(0);
230 break;
231 case wxWEB_VIEW_ZOOM_SMALL:
232 SetIETextZoom(1);
233 break;
234 case wxWEB_VIEW_ZOOM_MEDIUM:
235 SetIETextZoom(2);
236 break;
237 case wxWEB_VIEW_ZOOM_LARGE:
238 SetIETextZoom(3);
239 break;
240 case wxWEB_VIEW_ZOOM_LARGEST:
241 SetIETextZoom(4);
242 break;
243 default:
244 wxASSERT(false);
245 }
246 }
247
248 void wxWebViewIE::SetIETextZoom(int level)
249 {
250 VARIANT zoomVariant;
251 VariantInit (&zoomVariant);
252 V_VT(&zoomVariant) = VT_I4;
253 V_I4(&zoomVariant) = level;
254
255 HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
256 OLECMDEXECOPT_DONTPROMPTUSER,
257 &zoomVariant, NULL);
258 wxASSERT (result == S_OK);
259
260 VariantClear (&zoomVariant);
261 }
262
263 int wxWebViewIE::GetIETextZoom()
264 {
265 VARIANT zoomVariant;
266 VariantInit (&zoomVariant);
267 V_VT(&zoomVariant) = VT_I4;
268 V_I4(&zoomVariant) = 4;
269
270 HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
271 OLECMDEXECOPT_DONTPROMPTUSER,
272 NULL, &zoomVariant);
273 wxASSERT (result == S_OK);
274
275 int zoom = V_I4(&zoomVariant);
276 // wxMessageBox(wxString::Format("Zoom : %i", zoom));
277 VariantClear (&zoomVariant);
278
279 return zoom;
280 }
281
282 void wxWebViewIE::SetIEOpticalZoom(float zoom)
283 {
284 // TODO: add support for optical zoom (IE7+ only)
285
286 // TODO: get range from OLECMDID_OPTICAL_GETZOOMRANGE instead of hardcoding?
287 wxASSERT(zoom >= 10.0f);
288 wxASSERT(zoom <= 1000.0f);
289
290 VARIANT zoomVariant;
291 VariantInit (&zoomVariant);
292 V_VT(&zoomVariant) = VT_I4;
293 V_I4(&zoomVariant) = (zoom * 100.0f);
294
295 HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
296 OLECMDEXECOPT_DODEFAULT,
297 &zoomVariant,
298 NULL);
299 wxASSERT (result == S_OK);
300 }
301
302 float wxWebViewIE::GetIEOpticalZoom()
303 {
304 // TODO: add support for optical zoom (IE7+ only)
305
306 VARIANT zoomVariant;
307 VariantInit (&zoomVariant);
308 V_VT(&zoomVariant) = VT_I4;
309 V_I4(&zoomVariant) = -1;
310
311 HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
312 OLECMDEXECOPT_DODEFAULT, NULL,
313 &zoomVariant);
314 wxASSERT (result == S_OK);
315
316 const int zoom = V_I4(&zoomVariant);
317 VariantClear (&zoomVariant);
318
319 return zoom / 100.0f;
320 }
321
322 void wxWebViewIE::SetZoomType(wxWebViewZoomType)
323 {
324 // TODO: add support for optical zoom (IE7+ only)
325 wxASSERT(false);
326 }
327
328 wxWebViewZoomType wxWebViewIE::GetZoomType() const
329 {
330 // TODO: add support for optical zoom (IE7+ only)
331 return wxWEB_VIEW_ZOOM_TYPE_TEXT;
332 }
333
334 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType) const
335 {
336 // both are supported
337 // TODO: IE6 only supports text zoom, check if it's IE6 first
338 return true;
339 }
340
341 void wxWebViewIE::Print()
342 {
343 m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW,
344 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
345 }
346
347 void wxWebViewIE::GoBack()
348 {
349 wxVariant out = m_ie.CallMethod("GoBack");
350
351 // FIXME: why is out value null??
352 //return (HRESULT)(out.GetLong()) == S_OK;
353 }
354
355 void wxWebViewIE::GoForward()
356 {
357 wxVariant out = m_ie.CallMethod("GoForward");
358
359 // FIXME: why is out value null??
360 //return (HRESULT)(out.GetLong()) == S_OK;
361 }
362
363 void wxWebViewIE::Stop()
364 {
365 wxVariant out = m_ie.CallMethod("Stop");
366
367 // FIXME: why is out value null??
368 //return (HRESULT)(out.GetLong()) == S_OK;
369 }
370
371
372 void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
373 {
374 wxVariant out;
375
376 if (flags & wxWEB_VIEW_RELOAD_NO_CACHE)
377 {
378 VARIANTARG level;
379 level.vt = VT_I2;
380 level.iVal = 3;
381 out = m_ie.CallMethod("Refresh2", &level);
382 }
383 else
384 {
385 out = m_ie.CallMethod("Refresh");
386 }
387
388 if (out.GetType() != "null")
389 {
390 wxMessageBox("Non-null return message : " + out.GetType());
391 }
392 }
393
394 bool wxWebViewIE::IsOfflineMode()
395 {
396 wxVariant out = m_ie.GetProperty("Offline");
397
398 wxASSERT(out.GetType() == "bool");
399
400 return out.GetBool();
401 }
402
403 void wxWebViewIE::SetOfflineMode(bool offline)
404 {
405 // FIXME: the wxWidgets docs do not really document what the return
406 // parameter of PutProperty is
407 const bool success = m_ie.PutProperty("Offline", (offline ?
408 VARIANT_TRUE :
409 VARIANT_FALSE));
410 wxASSERT(success);
411 }
412
413 bool wxWebViewIE::IsBusy()
414 {
415 if (m_isBusy) return true;
416
417 wxVariant out = m_ie.GetProperty("Busy");
418
419 wxASSERT(out.GetType() == "bool");
420
421 return out.GetBool();
422 }
423
424 wxString wxWebViewIE::GetCurrentURL()
425 {
426 wxVariant out = m_ie.GetProperty("LocationURL");
427
428 wxASSERT(out.GetType() == "string");
429 return out.GetString();
430 }
431
432 wxString wxWebViewIE::GetCurrentTitle()
433 {
434 wxVariant out = m_ie.GetProperty("LocationName");
435
436 wxASSERT(out.GetType() == "string");
437 return out.GetString();
438 }
439
440 void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
441 {
442 if (m_webBrowser == NULL) return;
443
444 switch (evt.GetDispatchId())
445 {
446 case DISPID_BEFORENAVIGATE2:
447 {
448 m_isBusy = true;
449
450 wxString url = evt[1].GetString();
451 wxString target = evt[3].GetString();
452
453 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
454 GetId(), url, target, true);
455 event.SetEventObject(this);
456 HandleWindowEvent(event);
457
458 if (event.IsVetoed())
459 {
460 wxActiveXEventNativeMSW* nativeParams =
461 evt.GetNativeParameters();
462 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
463 }
464
465 // at this point, either the navigation event has been cancelled
466 // and we're not busy, either it was accepted and IWebBrowser2's
467 // Busy property will be true; so we don't need our override
468 // flag anymore.
469 m_isBusy = false;
470
471 break;
472 }
473
474 case DISPID_NAVIGATECOMPLETE2:
475 {
476 wxString url = evt[1].GetString();
477 // TODO: set target parameter if possible
478 wxString target = wxEmptyString;
479 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
480 GetId(), url, target, false);
481 event.SetEventObject(this);
482 HandleWindowEvent(event);
483 break;
484 }
485
486 case DISPID_PROGRESSCHANGE:
487 {
488 // download progress
489 break;
490 }
491
492 case DISPID_DOCUMENTCOMPLETE:
493 {
494 wxString url = evt[1].GetString();
495 // TODO: set target parameter if possible
496 wxString target = wxEmptyString;
497 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
498 url, target, false);
499 event.SetEventObject(this);
500 HandleWindowEvent(event);
501 break;
502 }
503
504 case DISPID_STATUSTEXTCHANGE:
505 {
506 break;
507 }
508
509 case DISPID_TITLECHANGE:
510 {
511 break;
512 }
513
514 case DISPID_NAVIGATEERROR:
515 {
516 wxWebNavigationError errorType = wxWEB_NAV_ERR_OTHER;
517 wxString errorCode = "?";
518 switch (evt[3].GetLong())
519 {
520 case INET_E_INVALID_URL: // (0x800C0002L or -2146697214)
521 errorCode = "INET_E_INVALID_URL";
522 errorType = wxWEB_NAV_ERR_REQUEST;
523 break;
524 case INET_E_NO_SESSION: // (0x800C0003L or -2146697213)
525 errorCode = "INET_E_NO_SESSION";
526 errorType = wxWEB_NAV_ERR_CONNECTION;
527 break;
528 case INET_E_CANNOT_CONNECT: // (0x800C0004L or -2146697212)
529 errorCode = "INET_E_CANNOT_CONNECT";
530 errorType = wxWEB_NAV_ERR_CONNECTION;
531 break;
532 case INET_E_RESOURCE_NOT_FOUND: // (0x800C0005L or -2146697211)
533 errorCode = "INET_E_RESOURCE_NOT_FOUND";
534 errorType = wxWEB_NAV_ERR_NOT_FOUND;
535 break;
536 case INET_E_OBJECT_NOT_FOUND: // (0x800C0006L or -2146697210)
537 errorCode = "INET_E_OBJECT_NOT_FOUND";
538 errorType = wxWEB_NAV_ERR_NOT_FOUND;
539 break;
540 case INET_E_DATA_NOT_AVAILABLE: // (0x800C0007L or -2146697209)
541 errorCode = "INET_E_DATA_NOT_AVAILABLE";
542 errorType = wxWEB_NAV_ERR_NOT_FOUND;
543 break;
544 case INET_E_DOWNLOAD_FAILURE: // (0x800C0008L or -2146697208)
545 errorCode = "INET_E_DOWNLOAD_FAILURE";
546 errorType = wxWEB_NAV_ERR_CONNECTION;
547 break;
548 case INET_E_AUTHENTICATION_REQUIRED: // (0x800C0009L or -2146697207)
549 errorCode = "INET_E_AUTHENTICATION_REQUIRED";
550 errorType = wxWEB_NAV_ERR_AUTH;
551 break;
552 case INET_E_NO_VALID_MEDIA: // (0x800C000AL or -2146697206)
553 errorCode = "INET_E_NO_VALID_MEDIA";
554 errorType = wxWEB_NAV_ERR_REQUEST;
555 break;
556 case INET_E_CONNECTION_TIMEOUT: // (0x800C000BL or -2146697205)
557 errorCode = "INET_E_CONNECTION_TIMEOUT";
558 errorType = wxWEB_NAV_ERR_CONNECTION;
559 break;
560 case INET_E_INVALID_REQUEST: // (0x800C000CL or -2146697204)
561 errorCode = "INET_E_INVALID_REQUEST";
562 errorType = wxWEB_NAV_ERR_REQUEST;
563 break;
564 case INET_E_UNKNOWN_PROTOCOL: // (0x800C000DL or -2146697203)
565 errorCode = "INET_E_UNKNOWN_PROTOCOL";
566 errorType = wxWEB_NAV_ERR_REQUEST;
567 break;
568 case INET_E_SECURITY_PROBLEM: // (0x800C000EL or -2146697202)
569 errorCode = "INET_E_SECURITY_PROBLEM";
570 errorType = wxWEB_NAV_ERR_SECURITY;
571 break;
572 case INET_E_CANNOT_LOAD_DATA: // (0x800C000FL or -2146697201)
573 errorCode = "INET_E_CANNOT_LOAD_DATA";
574 errorType = wxWEB_NAV_ERR_OTHER;
575 break;
576 case INET_E_CANNOT_INSTANTIATE_OBJECT:
577 // CoCreateInstance will return an error code if this happens,
578 // we'll handle this above.
579 return;
580 break;
581 case INET_E_REDIRECT_FAILED: // (0x800C0014L or -2146697196)
582 errorCode = "INET_E_REDIRECT_FAILED";
583 errorType = wxWEB_NAV_ERR_OTHER;
584 break;
585 case INET_E_REDIRECT_TO_DIR: // (0x800C0015L or -2146697195)
586 errorCode = "INET_E_REDIRECT_TO_DIR";
587 errorType = wxWEB_NAV_ERR_REQUEST;
588 break;
589 case INET_E_CANNOT_LOCK_REQUEST: // (0x800C0016L or -2146697194)
590 errorCode = "INET_E_CANNOT_LOCK_REQUEST";
591 errorType = wxWEB_NAV_ERR_OTHER;
592 break;
593 case INET_E_USE_EXTEND_BINDING: // (0x800C0017L or -2146697193)
594 errorCode = "INET_E_USE_EXTEND_BINDING";
595 errorType = wxWEB_NAV_ERR_OTHER;
596 break;
597 case INET_E_TERMINATED_BIND: // (0x800C0018L or -2146697192)
598 errorCode = "INET_E_TERMINATED_BIND";
599 errorType = wxWEB_NAV_ERR_OTHER;
600 break;
601 case INET_E_INVALID_CERTIFICATE: // (0x800C0019L or -2146697191)
602 errorCode = "INET_E_INVALID_CERTIFICATE";
603 errorType = wxWEB_NAV_ERR_CERTIFICATE;
604 break;
605 case INET_E_CODE_DOWNLOAD_DECLINED: // (0x800C0100L or -2146696960)
606 errorCode = "INET_E_CODE_DOWNLOAD_DECLINED";
607 errorType = wxWEB_NAV_ERR_USER_CANCELLED;
608 break;
609 case INET_E_RESULT_DISPATCHED: // (0x800C0200L or -2146696704)
610 // cancel request cancelled...
611 errorCode = "INET_E_RESULT_DISPATCHED";
612 errorType = wxWEB_NAV_ERR_OTHER;
613 break;
614 case INET_E_CANNOT_REPLACE_SFP_FILE: // (0x800C0300L or -2146696448)
615 errorCode = "INET_E_CANNOT_REPLACE_SFP_FILE";
616 errorType = wxWEB_NAV_ERR_SECURITY;
617 break;
618 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY:
619 errorCode = "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
620 errorType = wxWEB_NAV_ERR_SECURITY;
621 break;
622 case INET_E_CODE_INSTALL_SUPPRESSED:
623 errorCode = "INET_E_CODE_INSTALL_SUPPRESSED";
624 errorType = wxWEB_NAV_ERR_SECURITY;
625 break;
626 }
627
628 wxString url = evt[1].GetString();
629 wxString target = evt[2].GetString();
630 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
631 url, target, false);
632 event.SetEventObject(this);
633 event.SetInt(errorType);
634 event.SetString(errorCode);
635 HandleWindowEvent(event);
636 break;
637 }
638
639 case DISPID_COMMANDSTATECHANGE:
640 {
641 long commandId = evt[0].GetLong();
642 bool enable = evt[1].GetBool();
643 if (commandId == CSC_NAVIGATEBACK)
644 {
645 m_canNavigateBack = enable;
646 }
647 else if (commandId == CSC_NAVIGATEFORWARD)
648 {
649 m_canNavigateForward = enable;
650 }
651 }
652
653 /*
654 case DISPID_NEWWINDOW2:
655 //case DISPID_NEWWINDOW3:
656 {
657 wxLogMessage("DISPID_NEWWINDOW2\n");
658 wxActiveXEventNativeMSW* nativeParams = evt.GetNativeParameters();
659 // Cancel the attempt to open a new window
660 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
661 }*/
662 }
663
664 evt.Skip();
665 }
666
667 #endif