1 // Win32++ Version 7.3
\r
2 // Released: 30th November 2011
\r
6 // url: https://sourceforge.net/projects/win32-framework
\r
9 // Copyright (c) 2005-2011 David Nash
\r
11 // Permission is hereby granted, free of charge, to
\r
12 // any person obtaining a copy of this software and
\r
13 // associated documentation files (the "Software"),
\r
14 // to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify,
\r
16 // merge, publish, distribute, sublicense, and/or sell
\r
17 // copies of the Software, and to permit persons to whom
\r
18 // the Software is furnished to do so, subject to the
\r
19 // following conditions:
\r
21 // The above copyright notice and this permission notice
\r
22 // shall be included in all copies or substantial portions
\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.
\r
35 ////////////////////////////////////////////////////////
\r
37 #ifndef _WIN32XX_WEBBROWSER_H_
\r
38 #define _WIN32XX_WEBBROWSER_H_
\r
46 ///////////////////////////////////////////////////
\r
47 // Declaration of the CAXWindow class
\r
48 // This class implements an ActiveX control container
\r
49 class CAXWindow : public IOleClientSite, public IOleInPlaceSite, public IOleInPlaceFrame,
\r
50 public IOleControlSite, public IDispatch
\r
54 virtual ~CAXWindow();
\r
55 virtual void Activate(BOOL fFocus);
\r
56 virtual void CreateControl(BSTR bstrClsid);
\r
57 virtual void CreateControl(CLSID clsid);
\r
58 virtual void Remove();
\r
59 virtual void SetParent(HWND hWndParent);
\r
60 virtual void SetLocation(int x, int y, int width, int height);
\r
61 virtual void SetVisible(BOOL fVisible);
\r
62 virtual void SetStatusWindow(HWND hWndStatus);
\r
63 virtual void TranslateKey(MSG msg);
\r
64 IDispatch* GetDispatch();
\r
65 IUnknown* GetUnknown();
\r
68 STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);
\r
69 STDMETHODIMP_(ULONG) AddRef();
\r
70 STDMETHODIMP_(ULONG) Release();
\r
72 // IOleClientSite Methods
\r
73 STDMETHODIMP SaveObject();
\r
74 STDMETHODIMP GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER* ppMk);
\r
75 STDMETHODIMP GetContainer(LPOLECONTAINER* ppContainer);
\r
76 STDMETHODIMP ShowObject();
\r
77 STDMETHODIMP OnShowWindow(BOOL fShow);
\r
78 STDMETHODIMP RequestNewObjectLayout();
\r
80 // IOleWindow Methods
\r
81 STDMETHODIMP GetWindow(HWND* phwnd);
\r
82 STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
\r
84 // IOleInPlaceSite Methods
\r
85 STDMETHODIMP CanInPlaceActivate();
\r
86 STDMETHODIMP OnInPlaceActivate();
\r
87 STDMETHODIMP OnUIActivate();
\r
88 STDMETHODIMP GetWindowContext(IOleInPlaceFrame** ppFrame, IOleInPlaceUIWindow** ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo);
\r
89 STDMETHODIMP Scroll(SIZE scrollExtent);
\r
90 STDMETHODIMP OnUIDeactivate(BOOL fUndoable);
\r
91 STDMETHODIMP OnInPlaceDeactivate();
\r
92 STDMETHODIMP DiscardUndoState();
\r
93 STDMETHODIMP DeactivateAndUndo();
\r
94 STDMETHODIMP OnPosRectChange(LPCRECT lprcPosRect);
\r
96 // IOleInPlaceUIWindow Methods
\r
97 STDMETHODIMP GetBorder(LPRECT lprectBorder);
\r
98 STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS lpborderwidths);
\r
99 STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS lpborderwidths);
\r
100 STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR lpszObjName);
\r
102 // IOleInPlaceFrame Methods
\r
103 STDMETHODIMP InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
\r
104 STDMETHODIMP SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
\r
105 STDMETHODIMP RemoveMenus(HMENU hmenuShared);
\r
106 STDMETHODIMP SetStatusText(LPCOLESTR pszStatusText);
\r
107 STDMETHODIMP EnableModeless(BOOL fEnable);
\r
108 STDMETHODIMP TranslateAccelerator(LPMSG lpmsg, WORD wID);
\r
110 // IOleControlSite Methods
\r
111 STDMETHODIMP OnControlInfoChanged();
\r
112 STDMETHODIMP LockInPlaceActive(BOOL fLock);
\r
113 STDMETHODIMP GetExtendedControl(IDispatch** ppDisp);
\r
114 STDMETHODIMP TransformCoords(POINTL* pptlHimetric, POINTF* pptfContainer, DWORD dwFlags);
\r
115 STDMETHODIMP TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers);
\r
116 STDMETHODIMP OnFocus(BOOL fGotFocus);
\r
117 STDMETHODIMP ShowPropertyFrame();
\r
119 // IDispatch Methods
\r
120 STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, unsigned int cNames, LCID lcid, DISPID* rgdispid);
\r
121 STDMETHODIMP GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo** pptinfo);
\r
122 STDMETHODIMP GetTypeInfoCount(unsigned int* pctinfo);
\r
123 STDMETHODIMP Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexecinfo, unsigned int* puArgErr);
\r
126 ULONG m_cRefs; // ref count
\r
127 HWND m_hWnd; // window handle of the container
\r
128 HWND m_hWndStatus; // status window handle
\r
129 IUnknown* m_pUnk; // IUnknown of contained object
\r
130 CRect m_rcControl; // size of control
\r
134 ///////////////////////////////////////////////
\r
135 // Declaration of the CWebBrowser class
\r
136 // This class uses an AciveX Container provided by
\r
137 // CAXWindow to host the IWebBrower2 interface.
\r
138 class CWebBrowser : public CWnd
\r
142 virtual ~CWebBrowser();
\r
146 LPDISPATCH GetApplication() const;
\r
147 CAXWindow& GetAXWindow() const { return (CAXWindow&)m_AXContainer; }
\r
148 BOOL GetBusy() const;
\r
149 LPDISPATCH GetContainer() const;
\r
150 BOOL GetFullScreen() const;
\r
151 long GetHeight() const;
\r
152 IWebBrowser2* GetIWebBrowser2() const { return m_pIWebBrowser2; }
\r
153 long GetLeft() const;
\r
154 CString GetLocationName() const;
\r
155 CString GetLocationURL() const;
\r
156 BOOL GetOffline() const;
\r
157 READYSTATE GetReadyState() const;
\r
158 BOOL GetRegisterAsBrowser() const;
\r
159 BOOL GetTheaterMode() const;
\r
160 long GetTop() const;
\r
161 BOOL GetTopLevelContainer() const;
\r
162 CString GetType() const;
\r
163 BOOL GetVisible() const;
\r
164 long GetWidth() const;
\r
165 void SetFullScreen(BOOL bNewValue);
\r
166 void SetHeight(long nNewValue);
\r
167 void SetLeft(long nNewValue);
\r
168 void SetOffline(BOOL bNewValue);
\r
169 void SetRegisterAsBrowser(BOOL bNewValue);
\r
170 void SetTheaterMode(BOOL bNewValue);
\r
171 void SetTop(long nNewValue);
\r
172 void SetVisible(BOOL bNewValue);
\r
173 void SetWidth(long nNewValue);
\r
176 void AddWebBrowserControl(void);
\r
177 void ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut);
\r
178 BOOL GetProperty(LPCTSTR pszProperty, CString& strValue);
\r
179 VARIANT GetProperty( LPCTSTR pszProperty);
\r
184 void Navigate(LPCTSTR pszURL, DWORD dwFlags = 0, LPCTSTR pszTargetFrameName = NULL,
\r
185 LPCTSTR pszHeaders = NULL, LPVOID pvPostData = NULL, DWORD dwPostDataLen = 0);
\r
186 void Navigate2(LPITEMIDLIST pIDL, DWORD dwFlags = 0, LPCTSTR pszTargetFrameName = NULL);
\r
187 void Navigate2(LPCTSTR pszURL, DWORD dwFlags = 0, LPCTSTR pszTargetFrameName = NULL,
\r
188 LPCTSTR pszHeaders = NULL, LPVOID lpvPostData = NULL, DWORD dwPostDataLen = 0);
\r
189 void PutProperty(LPCTSTR pszPropertyName, const VARIANT& vtValue);
\r
190 void PutProperty(LPCTSTR pszPropertyName, double dValue);
\r
191 void PutProperty(LPCTSTR pszPropertyName, long lValue);
\r
192 void PutProperty(LPCTSTR pszPropertyName, LPCTSTR lpszValue);
\r
193 void PutProperty(LPCTSTR pszPropertyName, short nValue);
\r
195 void Refresh2(int nLevel);
\r
199 virtual void OnCreate();
\r
200 virtual void OnSize(int width, int height);
\r
201 virtual LRESULT WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam);
\r
204 CAXWindow m_AXContainer; // The ActiveX Container
\r
205 IWebBrowser2* m_pIWebBrowser2;// Interface to the ActiveX web browser control
\r
210 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
214 /////////////////////////////////////////
\r
215 // Global functions
\r
217 inline UINT GetPidlLength(LPITEMIDLIST pidl)
\r
220 UINT cbPidl = sizeof(pidl->mkid.cb);
\r
221 while(pidl && pidl->mkid.cb)
\r
223 cbPidl += pidl->mkid.cb;
\r
225 // Walk to next item
\r
226 BYTE* ptr = (BYTE*)pidl;
\r
227 ptr += pidl->mkid.cb;
\r
228 pidl = (LPITEMIDLIST)ptr;
\r
235 /////////////////////////////////////////
\r
236 // Definitions for the CAXWindow class
\r
238 inline CAXWindow::CAXWindow() : m_cRefs(1), m_hWnd(NULL), m_pUnk(NULL)
\r
242 inline CAXWindow::~CAXWindow()
\r
250 inline void CAXWindow::CreateControl(BSTR bstrClsid)
\r
253 CLSIDFromString(bstrClsid, &clsid);
\r
254 CreateControl(clsid);
\r
257 inline void CAXWindow::Activate(BOOL fFocus)
\r
265 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);
\r
269 pioo->DoVerb(OLEIVERB_UIACTIVATE, NULL, this, 0, m_hWnd, &m_rcControl);
\r
274 inline void CAXWindow::CreateControl(CLSID clsid)
\r
276 CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&m_pUnk);
\r
282 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);
\r
286 pioo->SetClientSite(this);
\r
289 IPersistStreamInit* ppsi;
\r
290 hr = m_pUnk->QueryInterface(IID_IPersistStreamInit, (void**)&ppsi);
\r
298 inline STDMETHODIMP_(ULONG) CAXWindow::AddRef()
\r
303 inline STDMETHODIMP CAXWindow::CanInPlaceActivate()
\r
308 inline STDMETHODIMP CAXWindow::ContextSensitiveHelp(BOOL fEnterMode)
\r
310 UNREFERENCED_PARAMETER(fEnterMode);
\r
314 inline STDMETHODIMP CAXWindow::DeactivateAndUndo()
\r
319 inline STDMETHODIMP CAXWindow::DiscardUndoState()
\r
324 inline STDMETHODIMP CAXWindow::EnableModeless(BOOL fEnable)
\r
326 UNREFERENCED_PARAMETER(fEnable);
\r
330 inline STDMETHODIMP CAXWindow::GetBorder(LPRECT lprectBorder)
\r
332 UNREFERENCED_PARAMETER(lprectBorder);
\r
336 inline STDMETHODIMP CAXWindow::GetContainer(LPOLECONTAINER* ppContainer)
\r
338 UNREFERENCED_PARAMETER(ppContainer);
\r
339 return E_NOINTERFACE;
\r
342 inline IDispatch* CAXWindow::GetDispatch()
\r
350 hr = m_pUnk->QueryInterface(IID_IDispatch, (void**)&pdisp);
\r
354 inline STDMETHODIMP CAXWindow::GetExtendedControl(IDispatch** ppDisp)
\r
356 if (ppDisp == NULL)
\r
357 return E_INVALIDARG;
\r
359 *ppDisp = (IDispatch*)this;
\r
360 (*ppDisp)->AddRef();
\r
365 inline STDMETHODIMP CAXWindow::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, unsigned int cNames, LCID lcid, DISPID* rgdispid)
\r
367 UNREFERENCED_PARAMETER((IID)riid); // IID cast required for the MinGW compiler
\r
368 UNREFERENCED_PARAMETER(rgszNames);
\r
369 UNREFERENCED_PARAMETER(cNames);
\r
370 UNREFERENCED_PARAMETER(lcid);
\r
372 *rgdispid = DISPID_UNKNOWN;
\r
373 return DISP_E_UNKNOWNNAME;
\r
376 inline STDMETHODIMP CAXWindow::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER* ppMk)
\r
378 UNREFERENCED_PARAMETER(dwAssign);
\r
379 UNREFERENCED_PARAMETER(dwWhichMoniker);
\r
380 UNREFERENCED_PARAMETER(ppMk);
\r
384 inline STDMETHODIMP CAXWindow::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo** pptinfo)
\r
386 UNREFERENCED_PARAMETER(itinfo);
\r
387 UNREFERENCED_PARAMETER(lcid);
\r
388 UNREFERENCED_PARAMETER(pptinfo);
\r
392 inline STDMETHODIMP CAXWindow::GetTypeInfoCount(unsigned int* pctinfo)
\r
394 UNREFERENCED_PARAMETER(pctinfo);
\r
398 inline IUnknown* CAXWindow::GetUnknown()
\r
407 inline STDMETHODIMP CAXWindow::GetWindow(HWND* lphwnd)
\r
409 if (!IsWindow(m_hWnd))
\r
416 inline STDMETHODIMP CAXWindow::GetWindowContext (IOleInPlaceFrame** ppFrame, IOleInPlaceUIWindow** ppIIPUIWin,
\r
417 LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
\r
419 *ppFrame = (IOleInPlaceFrame*)this;
\r
420 *ppIIPUIWin = NULL;
\r
423 GetClientRect(m_hWnd, &rect);
\r
424 lprcPosRect->left = 0;
\r
425 lprcPosRect->top = 0;
\r
426 lprcPosRect->right = rect.right;
\r
427 lprcPosRect->bottom = rect.bottom;
\r
429 CopyRect(lprcClipRect, lprcPosRect);
\r
431 lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
\r
432 lpFrameInfo->fMDIApp = FALSE;
\r
433 lpFrameInfo->hwndFrame = m_hWnd;
\r
434 lpFrameInfo->haccel = 0;
\r
435 lpFrameInfo->cAccelEntries = 0;
\r
437 (*ppFrame)->AddRef();
\r
441 inline STDMETHODIMP CAXWindow::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
\r
443 UNREFERENCED_PARAMETER(hmenuShared);
\r
444 UNREFERENCED_PARAMETER(lpMenuWidths);
\r
448 inline STDMETHODIMP CAXWindow::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexecinfo, unsigned int* puArgErr)
\r
450 UNREFERENCED_PARAMETER(dispid);
\r
451 UNREFERENCED_PARAMETER((IID)riid); // IID cast required for the MinGW compiler
\r
452 UNREFERENCED_PARAMETER(lcid);
\r
453 UNREFERENCED_PARAMETER(wFlags);
\r
454 UNREFERENCED_PARAMETER(pdispparams);
\r
455 UNREFERENCED_PARAMETER(pvarResult);
\r
456 UNREFERENCED_PARAMETER(pexecinfo);
\r
457 UNREFERENCED_PARAMETER(puArgErr);
\r
458 return DISP_E_MEMBERNOTFOUND;
\r
461 inline STDMETHODIMP CAXWindow::LockInPlaceActive(BOOL fLock)
\r
463 UNREFERENCED_PARAMETER(fLock);
\r
467 inline STDMETHODIMP CAXWindow::OnControlInfoChanged()
\r
472 inline STDMETHODIMP CAXWindow::OnFocus(BOOL fGotFocus)
\r
474 UNREFERENCED_PARAMETER(fGotFocus);
\r
478 inline STDMETHODIMP CAXWindow::OnInPlaceActivate()
\r
483 inline STDMETHODIMP CAXWindow::OnInPlaceDeactivate()
\r
488 inline STDMETHODIMP CAXWindow::OnPosRectChange(LPCRECT lprcPosRect)
\r
490 UNREFERENCED_PARAMETER(lprcPosRect);
\r
494 inline STDMETHODIMP CAXWindow::OnShowWindow(BOOL fShow)
\r
496 UNREFERENCED_PARAMETER(fShow);
\r
500 inline STDMETHODIMP CAXWindow::OnUIActivate()
\r
505 inline STDMETHODIMP CAXWindow::OnUIDeactivate(BOOL fUndoable)
\r
507 UNREFERENCED_PARAMETER(fUndoable);
\r
511 inline STDMETHODIMP CAXWindow::QueryInterface(REFIID riid, void** ppvObject)
\r
516 if (IsEqualIID(riid, IID_IOleClientSite))
\r
517 *ppvObject = (IOleClientSite*)this;
\r
518 else if (IsEqualIID(riid, IID_IOleInPlaceSite))
\r
519 *ppvObject = (IOleInPlaceSite*)this;
\r
520 else if (IsEqualIID(riid, IID_IOleInPlaceFrame))
\r
521 *ppvObject = (IOleInPlaceFrame*)this;
\r
522 else if (IsEqualIID(riid, IID_IOleInPlaceUIWindow))
\r
523 *ppvObject = (IOleInPlaceUIWindow*)this;
\r
524 else if (IsEqualIID(riid, IID_IOleControlSite))
\r
525 *ppvObject = (IOleControlSite*)this;
\r
526 else if (IsEqualIID(riid, IID_IOleWindow))
\r
528 else if (IsEqualIID(riid, IID_IDispatch))
\r
529 *ppvObject = (IDispatch*)this;
\r
530 else if (IsEqualIID(riid, IID_IUnknown))
\r
535 return E_NOINTERFACE;
\r
542 inline STDMETHODIMP_(ULONG) CAXWindow::Release()
\r
547 inline void CAXWindow::Remove()
\r
553 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);
\r
556 pioo->Close(OLECLOSE_NOSAVE);
\r
557 pioo->SetClientSite(NULL);
\r
561 IOleInPlaceObject* pipo;
\r
562 hr = m_pUnk->QueryInterface(IID_IOleInPlaceObject, (void**)&pipo);
\r
565 pipo->UIDeactivate();
\r
566 pipo->InPlaceDeactivate();
\r
572 inline STDMETHODIMP CAXWindow::RemoveMenus(HMENU hmenuShared)
\r
574 UNREFERENCED_PARAMETER(hmenuShared);
\r
578 inline STDMETHODIMP CAXWindow::RequestBorderSpace(LPCBORDERWIDTHS lpborderwidths)
\r
580 UNREFERENCED_PARAMETER(lpborderwidths);
\r
584 inline STDMETHODIMP CAXWindow::RequestNewObjectLayout()
\r
589 inline STDMETHODIMP CAXWindow::SaveObject()
\r
594 inline STDMETHODIMP CAXWindow::Scroll(SIZE scrollExtent)
\r
596 UNREFERENCED_PARAMETER(scrollExtent);
\r
600 inline STDMETHODIMP CAXWindow::SetActiveObject(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR lpszObjName)
\r
602 UNREFERENCED_PARAMETER(pActiveObject);
\r
603 UNREFERENCED_PARAMETER(lpszObjName);
\r
607 inline STDMETHODIMP CAXWindow::SetBorderSpace(LPCBORDERWIDTHS lpborderwidths)
\r
609 UNREFERENCED_PARAMETER(lpborderwidths);
\r
613 inline void CAXWindow::SetLocation(int x, int y, int width, int height)
\r
615 m_rcControl.SetRect(x, y, x + width, y + height);
\r
620 IOleInPlaceObject* pipo;
\r
621 HRESULT hr = m_pUnk->QueryInterface(IID_IOleInPlaceObject, (void**)&pipo);
\r
625 pipo->SetObjectRects(&m_rcControl, &m_rcControl);
\r
629 inline STDMETHODIMP CAXWindow::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
\r
631 UNREFERENCED_PARAMETER(hmenuShared);
\r
632 UNREFERENCED_PARAMETER(holemenu);
\r
633 UNREFERENCED_PARAMETER(hwndActiveObject);
\r
637 inline void CAXWindow::SetParent(HWND hWndParent)
\r
639 m_hWnd = hWndParent;
\r
642 inline STDMETHODIMP CAXWindow::SetStatusText(LPCOLESTR pszStatusText)
\r
644 if (NULL == pszStatusText)
\r
648 char status[MAX_PATH];
\r
649 // Convert the Wide string to char
\r
650 WideCharToMultiByte(CP_ACP, 0, pszStatusText, -1, status, MAX_PATH, NULL, NULL);
\r
652 if (IsWindow(m_hWndStatus))
\r
653 SendMessage(m_hWndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)status);
\r
655 if (IsWindow(m_hWndStatus))
\r
656 SendMessage(m_hWndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)pszStatusText);
\r
662 inline void CAXWindow::SetStatusWindow(HWND hWndStatus)
\r
664 m_hWndStatus = hWndStatus;
\r
667 inline void CAXWindow::SetVisible(BOOL fVisible)
\r
673 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);
\r
679 pioo->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, this, 0, m_hWnd, &m_rcControl);
\r
680 pioo->DoVerb(OLEIVERB_SHOW, NULL, this, 0, m_hWnd, &m_rcControl);
\r
683 pioo->DoVerb(OLEIVERB_HIDE, NULL, this, 0, m_hWnd, NULL);
\r
688 inline STDMETHODIMP CAXWindow::ShowObject()
\r
693 inline STDMETHODIMP CAXWindow::ShowPropertyFrame()
\r
698 inline STDMETHODIMP CAXWindow::TransformCoords(POINTL* pptlHimetric, POINTF* pptfContainer, DWORD dwFlags)
\r
700 UNREFERENCED_PARAMETER(pptlHimetric);
\r
701 UNREFERENCED_PARAMETER(pptfContainer);
\r
702 UNREFERENCED_PARAMETER(dwFlags);
\r
706 inline STDMETHODIMP CAXWindow::TranslateAccelerator(LPMSG lpmsg, WORD wID)
\r
708 UNREFERENCED_PARAMETER(lpmsg);
\r
709 UNREFERENCED_PARAMETER(wID);
\r
713 inline STDMETHODIMP CAXWindow::TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers)
\r
715 UNREFERENCED_PARAMETER(pMsg);
\r
716 UNREFERENCED_PARAMETER(grfModifiers);
\r
720 inline void CAXWindow::TranslateKey(MSG msg)
\r
725 IOleInPlaceActiveObject* pao;
\r
726 HRESULT hr = m_pUnk->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pao);
\r
730 pao->TranslateAccelerator(&msg);
\r
735 ////////////////////////////////////////
\r
736 // Definitions for the CWebBrowser class
\r
738 inline CWebBrowser::CWebBrowser() : m_pIWebBrowser2(0)
\r
740 OleInitialize(NULL);
\r
743 inline CWebBrowser::~CWebBrowser()
\r
745 if (m_pIWebBrowser2)
\r
747 m_pIWebBrowser2->Stop();
\r
748 m_pIWebBrowser2->Release();
\r
754 inline void CWebBrowser::AddWebBrowserControl()
\r
756 GetAXWindow().CreateControl(CLSID_WebBrowser);
\r
757 GetAXWindow().SetParent(m_hWnd);
\r
758 GetAXWindow().SetVisible(TRUE);
\r
759 GetAXWindow().Activate(TRUE);
\r
761 IUnknown* pUnk = GetAXWindow().GetUnknown();
\r
764 // Store the pointer to the WebBrowser control
\r
765 HRESULT hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&m_pIWebBrowser2);
\r
768 // Navigate to an empty page
\r
771 m_pIWebBrowser2->Navigate((OLECHAR*)L"about:blank", 0, 0, 0, 0);
\r
776 inline void CWebBrowser::OnCreate()
\r
778 AddWebBrowserControl();
\r
781 inline void CWebBrowser::OnSize(int width, int height)
\r
783 // position the container
\r
784 GetAXWindow().SetLocation(0, 0, width, height);
\r
787 inline LRESULT CWebBrowser::WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam)
\r
792 OnSize(LOWORD(lParam), HIWORD(lParam));
\r
795 GetAXWindow().Remove();
\r
799 return CWnd::WndProcDefault(uMsg, wParam, lParam);
\r
802 inline LPDISPATCH CWebBrowser::GetApplication() const
\r
803 // Retrieves the automation object for the application that is hosting the WebBrowser Control.
\r
806 GetIWebBrowser2()->get_Application(&Value);
\r
810 inline BOOL CWebBrowser::GetBusy() const
\r
811 // Retrieves a value that indicates whether the object is engaged in a navigation or downloading operation.
\r
813 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
814 GetIWebBrowser2()->get_Busy(&bValue);
\r
815 return (BOOL)bValue;
\r
818 inline LPDISPATCH CWebBrowser::GetContainer() const
\r
819 // Retrieves an object reference to a container.
\r
822 GetIWebBrowser2()->get_Container(&Value);
\r
826 inline BOOL CWebBrowser::GetFullScreen() const
\r
827 // Retrieves a value that indicates whether Internet Explorer is in full-screen mode or normal window mode.
\r
829 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
830 GetIWebBrowser2()->get_FullScreen(&bValue);
\r
831 return (BOOL)bValue;
\r
834 inline long CWebBrowser::GetHeight() const
\r
835 // Retrieves the height of the object.
\r
838 GetIWebBrowser2()->get_Height(&lValue);
\r
842 inline long CWebBrowser::GetLeft() const
\r
843 // Retrieves the coordinate of the left edge of the object.
\r
846 GetIWebBrowser2()->get_Left(&lValue);
\r
850 inline CString CWebBrowser::GetLocationName() const
\r
851 // Retrieves the path or title of the resource that is currently displayed.
\r
854 GetIWebBrowser2()->get_LocationName(&bstr);
\r
856 SysFreeString(bstr);
\r
860 inline CString CWebBrowser::GetLocationURL() const
\r
861 // Retrieves the URL of the resource that is currently displayed.
\r
864 GetIWebBrowser2()->get_LocationURL(&bstr);
\r
866 SysFreeString(bstr);
\r
870 inline BOOL CWebBrowser::GetOffline() const
\r
871 // Retrieves a value that indicates whether the object is operating in offline mode.
\r
873 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
874 GetIWebBrowser2()->get_Offline(&bValue);
\r
875 return (BOOL)bValue;
\r
878 inline READYSTATE CWebBrowser::GetReadyState() const
\r
879 // Retrieves the ready state of the object.
\r
881 READYSTATE rsValue;
\r
882 GetIWebBrowser2()->get_ReadyState(&rsValue);
\r
886 inline BOOL CWebBrowser::GetRegisterAsBrowser() const
\r
887 // Retrieves a value that indicates whether the object is registered as a top-level browser window.
\r
889 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
890 #if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)
\r
891 GetIWebBrowser2()->get_RegisterAsBrowser(&bValue);
\r
893 return (BOOL)bValue;
\r
896 inline BOOL CWebBrowser::GetTheaterMode() const
\r
897 // Retrieves the theater mode state of the object.
\r
899 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
900 GetIWebBrowser2()->get_TheaterMode(&bValue);
\r
901 return (BOOL)bValue;
\r
904 inline long CWebBrowser::GetTop() const
\r
905 // Retrieves the coordinate of the top edge of the object.
\r
908 GetIWebBrowser2()->get_Top(&lValue);
\r
912 inline BOOL CWebBrowser::GetTopLevelContainer() const
\r
913 //Retrieves a value that indicates whether the object is a top-level container.
\r
915 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
916 GetIWebBrowser2()->get_TopLevelContainer(&bValue);
\r
917 return (BOOL)bValue;
\r
920 inline CString CWebBrowser::GetType() const
\r
921 // Retrieves the user type name of the contained document object.
\r
924 GetIWebBrowser2()->get_Type(&bString);
\r
925 CString str(bString);
\r
926 SysFreeString(bString);
\r
930 inline BOOL CWebBrowser::GetVisible() const
\r
931 // Retrieves a value that indicates whether the object is visible or hidden.
\r
933 VARIANT_BOOL bValue = VARIANT_FALSE;
\r
934 GetIWebBrowser2()->get_Visible(&bValue);
\r
935 return (BOOL)bValue;
\r
938 inline long CWebBrowser::GetWidth() const
\r
939 // Retrieves the width of the object.
\r
942 GetIWebBrowser2()->get_Width(&lValue);
\r
946 inline void CWebBrowser::SetFullScreen(BOOL bNewValue)
\r
947 // Sets a value that indicates whether Internet Explorer is in full-screen mode or normal window mode.
\r
949 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;
\r
950 GetIWebBrowser2()->put_FullScreen(vBool);
\r
953 inline void CWebBrowser::SetHeight(long nNewValue)
\r
954 // Sets the height of the object.
\r
956 GetIWebBrowser2()->put_Height(nNewValue);
\r
959 inline void CWebBrowser::SetLeft(long nNewValue)
\r
960 // Sets the coordinate of the left edge of the object.
\r
962 GetIWebBrowser2()->put_Left(nNewValue);
\r
965 inline void CWebBrowser::SetOffline(BOOL bNewValue)
\r
966 // Sets a value that indicates whether the object is operating in offline mode.
\r
968 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;
\r
969 GetIWebBrowser2()->put_Offline(vBool);
\r
972 inline void CWebBrowser::SetRegisterAsBrowser(BOOL bNewValue)
\r
973 // Sets a value that indicates whether the object is registered as a top-level browser window.
\r
975 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;
\r
976 GetIWebBrowser2()->put_RegisterAsBrowser(vBool);
\r
979 inline void CWebBrowser::SetTheaterMode(BOOL bNewValue)
\r
980 // Sets the theatre mode state of the object.
\r
982 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;
\r
983 GetIWebBrowser2()->put_TheaterMode(vBool);
\r
986 inline void CWebBrowser::SetTop(long nNewValue)
\r
987 // Sets the coordinate of the top edge of the object.
\r
989 GetIWebBrowser2()->put_Top(nNewValue);
\r
992 inline void CWebBrowser::SetVisible(BOOL bNewValue)
\r
993 // Sets a value that indicates whether the object is visible or hidden.
\r
995 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;
\r
996 GetIWebBrowser2()->put_Visible(vBool);
\r
999 inline void CWebBrowser::SetWidth(long nNewValue)
\r
1000 // Sets the width of the object.
\r
1002 GetIWebBrowser2()->put_Width(nNewValue);
\r
1005 inline void CWebBrowser::ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut)
\r
1006 // Executes a command using the IOleCommandTarget interface.
\r
1008 GetIWebBrowser2()->ExecWB(cmdID, cmdexecopt, pvaIn, pvaOut);
\r
1011 inline BOOL CWebBrowser::GetProperty(LPCTSTR pszProperty, CString& strValue)
\r
1012 // Gets the value associated with the specified property name.
\r
1015 HRESULT hResult = GetIWebBrowser2()->GetProperty(T2BSTR(pszProperty), &v);
\r
1016 if (v.vt == VT_EMPTY)
\r
1019 strValue = BSTR2T(v.bstrVal);
\r
1021 return (hResult == S_OK);
\r
1024 inline VARIANT CWebBrowser::GetProperty( LPCTSTR pszProperty )
\r
1025 // Gets the value associated with the specified property name.
\r
1028 GetIWebBrowser2()->GetProperty( T2BSTR(pszProperty), &v );
\r
1032 inline void CWebBrowser::GoBack()
\r
1033 // Navigates backward one item in the history list.
\r
1035 GetIWebBrowser2()->GoBack();
\r
1038 inline void CWebBrowser::GoForward()
\r
1039 // Navigates forward one item in the history list.
\r
1041 GetIWebBrowser2()->GoForward();
\r
1044 inline void CWebBrowser::GoHome()
\r
1045 // Navigates to the current home or start page.
\r
1047 GetIWebBrowser2()->GoHome();
\r
1050 inline void CWebBrowser::GoSearch()
\r
1051 // Navigates to the current search page.
\r
1053 GetIWebBrowser2()->GoSearch();
\r
1056 inline void CWebBrowser::Navigate(LPCTSTR pszURL, DWORD dwFlags /*= 0*/, LPCTSTR pszTargetFrameName /*= NULL*/,
\r
1057 LPCTSTR pszHeaders /*= NULL*/, LPVOID pvPostData /*= NULL*/, DWORD dwPostDataLen /*= 0*/)
\r
1058 // Navigates to a resource identified by a URL or to a file identified by a full path.
\r
1062 Flags.lVal = dwFlags;
\r
1064 VARIANT TargetFrameName;
\r
1065 TargetFrameName.vt = VT_BSTR;
\r
1066 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));
\r
1068 SAFEARRAY* psa = SafeArrayCreateVector(VT_UI1, 0, dwPostDataLen);
\r
1069 CopyMemory(psa->pvData, pvPostData, dwPostDataLen);
\r
1071 PostData.vt = VT_ARRAY|VT_UI1;
\r
1072 PostData.parray = psa;
\r
1075 Headers.vt = VT_BSTR;
\r
1076 Headers.bstrVal = SysAllocString(T2W(pszHeaders));
\r
1077 BSTR url = SysAllocString(T2W(pszURL));
\r
1079 GetIWebBrowser2()->Navigate(url, &Flags, &TargetFrameName, &PostData, &Headers);
\r
1081 VariantClear(&Flags);
\r
1082 VariantClear(&TargetFrameName);
\r
1083 VariantClear(&PostData);
\r
1084 VariantClear(&Headers);
\r
1087 inline void CWebBrowser::Navigate2(LPITEMIDLIST pIDL, DWORD dwFlags /*= 0*/, LPCTSTR pszTargetFrameName /*= NULL*/)
\r
1088 // Navigates the browser to a location specified by a pointer to an item identifier list (PIDL) for an entity in the Microsoft Windows Shell namespace.
\r
1090 UINT cb = GetPidlLength(pIDL);
\r
1091 LPSAFEARRAY psa = SafeArrayCreateVector(VT_UI1, 0, cb);
\r
1093 PIDL.vt = VT_ARRAY|VT_UI1;
\r
1094 PIDL.parray = psa;
\r
1095 CopyMemory(psa->pvData, pIDL, cb);
\r
1099 Flags.lVal = dwFlags;
\r
1101 VARIANT TargetFrameName;
\r
1102 TargetFrameName.vt = VT_BSTR;
\r
1103 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));
\r
1105 GetIWebBrowser2()->Navigate2(&PIDL, &Flags, &TargetFrameName, 0, 0);
\r
1107 VariantClear(&PIDL);
\r
1108 VariantClear(&Flags);
\r
1109 VariantClear(&TargetFrameName);
\r
1112 inline void CWebBrowser::Navigate2(LPCTSTR pszURL, DWORD dwFlags /*= 0*/, LPCTSTR pszTargetFrameName /*= NULL*/,
\r
1113 LPCTSTR pszHeaders /*= NULL*/, LPVOID pvPostData /*= NULL*/, DWORD dwPostDataLen /*= 0*/)
\r
1114 // Navigates the browser to a location that is expressed as a URL.
\r
1118 URL.bstrVal = SysAllocString(T2W(pszURL));
\r
1122 Flags.lVal = dwFlags;
\r
1124 VARIANT TargetFrameName;
\r
1125 TargetFrameName.vt = VT_BSTR;
\r
1126 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));
\r
1128 // Store the pidl in a SafeArray, and assign the SafeArray to a VARIANT
\r
1129 SAFEARRAY* psa = SafeArrayCreateVector(VT_UI1, 0, dwPostDataLen);
\r
1130 CopyMemory(psa->pvData, pvPostData, dwPostDataLen);
\r
1132 PostData.vt = VT_ARRAY|VT_UI1;
\r
1133 PostData.parray = psa;
\r
1136 Headers.vt = VT_BSTR;
\r
1137 Headers.bstrVal = SysAllocString(T2W(pszHeaders));
\r
1139 GetIWebBrowser2()->Navigate2(&URL, &Flags, &TargetFrameName, &PostData, &Headers);
\r
1141 VariantClear(&URL);
\r
1142 VariantClear(&Flags);
\r
1143 VariantClear(&TargetFrameName);
\r
1144 VariantClear(&PostData);
\r
1145 VariantClear(&Headers);
\r
1148 inline void CWebBrowser::PutProperty(LPCTSTR pszProperty, const VARIANT& vtValue)
\r
1149 // Sets the value of a property associated with the object.
\r
1151 GetIWebBrowser2()->PutProperty(T2BSTR(pszProperty), vtValue);
\r
1154 inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, double dValue)
\r
1155 // Sets the value of a property associated with the object.
\r
1159 v.dblVal = dValue;
\r
1160 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);
\r
1164 inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, long lValue)
\r
1165 // Sets the value of a property associated with the object.
\r
1170 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);
\r
1174 inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, LPCTSTR lpszValue)
\r
1175 // Sets the value of a property associated with the object.
\r
1179 v.bstrVal= SysAllocString(T2W(lpszValue));
\r
1180 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);
\r
1184 inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, short nValue)
\r
1185 // Sets the value of a property associated with the object.
\r
1190 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);
\r
1194 inline void CWebBrowser::Refresh()
\r
1195 // Reloads the file that is currently displayed in the object.
\r
1197 GetIWebBrowser2()->Refresh();
\r
1200 inline void CWebBrowser::Refresh2(int nLevel)
\r
1201 // Reloads the file that is currently displayed with the specified refresh level.
\r
1205 v.intVal = nLevel;
\r
1206 GetIWebBrowser2()->Refresh2(&v);
\r
1210 inline void CWebBrowser::Stop()
\r
1211 // Cancels a pending navigation or download, and stops dynamic page elements, such as background sounds and animations.
\r
1213 GetIWebBrowser2()->Stop();
\r
1219 #endif // _WIN32XX_WEBBROWSER_H_
\r