Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / TOF / Win32++ / include / webbrowser.h
1 // Win32++   Version 7.3\r
2 // Released: 30th November 2011\r
3 //\r
4 //      David Nash\r
5 //      email: [email protected]\r
6 //      url: https://sourceforge.net/projects/win32-framework\r
7 //\r
8 //\r
9 // Copyright (c) 2005-2011  David Nash\r
10 //\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
20 //\r
21 // The above copyright notice and this permission notice\r
22 // shall be included in all copies or substantial portions\r
23 // of the Software.\r
24 //\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
34 //\r
35 ////////////////////////////////////////////////////////\r
36 \r
37 #ifndef _WIN32XX_WEBBROWSER_H_\r
38 #define _WIN32XX_WEBBROWSER_H_\r
39 \r
40 #include <exdisp.h>\r
41 #include <ocidl.h>\r
42 #include <shlobj.h>\r
43 \r
44 namespace Win32xx\r
45 {\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
51         {\r
52         public:\r
53                 CAXWindow();\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
66 \r
67                 // IUnknown Methods\r
68                 STDMETHODIMP QueryInterface(REFIID riid, void** ppvObject);\r
69                 STDMETHODIMP_(ULONG) AddRef();\r
70                 STDMETHODIMP_(ULONG) Release();\r
71 \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
79 \r
80                 // IOleWindow Methods\r
81                 STDMETHODIMP GetWindow(HWND* phwnd);\r
82                 STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);\r
83 \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
95 \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
101 \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
109 \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
118 \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
124 \r
125         private:\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
131         };\r
132 \r
133 \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
139         {\r
140         public:\r
141                 CWebBrowser();\r
142                 virtual ~CWebBrowser();\r
143                 \r
144                 \r
145                 //Attributes\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
174 \r
175                 // Operations\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
180                 void GoBack();\r
181                 void GoForward();\r
182                 void GoHome();\r
183                 void GoSearch();\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
194                 void Refresh();\r
195                 void Refresh2(int nLevel);\r
196                 void Stop();\r
197 \r
198         protected:\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
202 \r
203         private:\r
204                 CAXWindow       m_AXContainer;          // The ActiveX Container\r
205                 IWebBrowser2*   m_pIWebBrowser2;// Interface to the ActiveX web browser control\r
206         };\r
207 \r
208 }\r
209 \r
210 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
211 \r
212 namespace Win32xx\r
213 {\r
214         /////////////////////////////////////////\r
215         // Global functions\r
216         //\r
217         inline UINT GetPidlLength(LPITEMIDLIST pidl)\r
218         {\r
219                 assert(pidl);\r
220                 UINT cbPidl = sizeof(pidl->mkid.cb);\r
221                 while(pidl && pidl->mkid.cb)\r
222                 {\r
223                         cbPidl += pidl->mkid.cb;\r
224 \r
225                         // Walk to next item\r
226                         BYTE* ptr = (BYTE*)pidl;\r
227                         ptr += pidl->mkid.cb;\r
228                         pidl = (LPITEMIDLIST)ptr;\r
229                 }\r
230 \r
231                 return cbPidl;\r
232         }\r
233 \r
234 \r
235         /////////////////////////////////////////\r
236         // Definitions for the CAXWindow class\r
237         //\r
238         inline CAXWindow::CAXWindow() : m_cRefs(1), m_hWnd(NULL), m_pUnk(NULL)\r
239         {\r
240         }\r
241 \r
242         inline CAXWindow::~CAXWindow()\r
243         {\r
244                 if (m_pUnk)\r
245                         m_pUnk->Release();\r
246 \r
247                 Release();\r
248         }\r
249 \r
250         inline void CAXWindow::CreateControl(BSTR bstrClsid)\r
251         {\r
252                 CLSID   clsid;\r
253                 CLSIDFromString(bstrClsid, &clsid);\r
254                 CreateControl(clsid);\r
255         }\r
256 \r
257         inline void CAXWindow::Activate(BOOL fFocus)\r
258         {\r
259                 if (!m_pUnk)\r
260                         return;\r
261 \r
262                 if (fFocus)\r
263                 {\r
264                         IOleObject* pioo;\r
265                         HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);\r
266                         if (FAILED(hr))\r
267                                 return;\r
268 \r
269                         pioo->DoVerb(OLEIVERB_UIACTIVATE, NULL, this, 0, m_hWnd, &m_rcControl);\r
270                         pioo->Release();\r
271                 }\r
272         }\r
273 \r
274         inline void CAXWindow::CreateControl(CLSID clsid)\r
275         {\r
276                 CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&m_pUnk);\r
277 \r
278                 if (!m_pUnk)\r
279                         return;\r
280 \r
281                 IOleObject* pioo;\r
282                 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);\r
283                 if (FAILED(hr))\r
284                         return;\r
285 \r
286                 pioo->SetClientSite(this);\r
287                 pioo->Release();\r
288 \r
289                 IPersistStreamInit* ppsi;\r
290                 hr = m_pUnk->QueryInterface(IID_IPersistStreamInit, (void**)&ppsi);\r
291                 if (SUCCEEDED(hr))\r
292                 {\r
293                         ppsi->InitNew();\r
294                         ppsi->Release();\r
295                 }\r
296         }\r
297 \r
298         inline STDMETHODIMP_(ULONG) CAXWindow::AddRef()\r
299         {\r
300                 return ++m_cRefs;\r
301         }\r
302 \r
303         inline STDMETHODIMP CAXWindow::CanInPlaceActivate()\r
304         {\r
305                 return S_OK;\r
306         }\r
307 \r
308         inline STDMETHODIMP CAXWindow::ContextSensitiveHelp(BOOL fEnterMode)\r
309         {\r
310                 UNREFERENCED_PARAMETER(fEnterMode);\r
311                 return E_NOTIMPL;\r
312         }\r
313 \r
314         inline STDMETHODIMP CAXWindow::DeactivateAndUndo()\r
315         {\r
316                 return E_NOTIMPL;\r
317         }\r
318 \r
319         inline STDMETHODIMP CAXWindow::DiscardUndoState()\r
320         {\r
321                 return E_NOTIMPL;\r
322         }\r
323 \r
324         inline STDMETHODIMP CAXWindow::EnableModeless(BOOL fEnable)\r
325         {\r
326                 UNREFERENCED_PARAMETER(fEnable);\r
327                 return E_NOTIMPL;\r
328         }\r
329 \r
330         inline STDMETHODIMP CAXWindow::GetBorder(LPRECT lprectBorder)\r
331         {\r
332                 UNREFERENCED_PARAMETER(lprectBorder);\r
333                 return E_NOTIMPL;\r
334         }\r
335 \r
336         inline STDMETHODIMP CAXWindow::GetContainer(LPOLECONTAINER* ppContainer)\r
337         {\r
338                 UNREFERENCED_PARAMETER(ppContainer);\r
339                 return E_NOINTERFACE;\r
340         }\r
341 \r
342         inline IDispatch* CAXWindow::GetDispatch()\r
343         {\r
344                 if (!m_pUnk)\r
345                         return NULL;\r
346 \r
347                 HRESULT     hr;\r
348                 IDispatch*  pdisp;\r
349 \r
350                 hr = m_pUnk->QueryInterface(IID_IDispatch, (void**)&pdisp);\r
351                 return pdisp;\r
352         }\r
353 \r
354         inline STDMETHODIMP CAXWindow::GetExtendedControl(IDispatch** ppDisp)\r
355         {\r
356                 if (ppDisp == NULL)\r
357                         return E_INVALIDARG;\r
358 \r
359                 *ppDisp = (IDispatch*)this;\r
360                 (*ppDisp)->AddRef();\r
361 \r
362                 return S_OK;\r
363         }\r
364 \r
365         inline STDMETHODIMP CAXWindow::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, unsigned int cNames, LCID lcid, DISPID* rgdispid)\r
366         {\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
371 \r
372                 *rgdispid = DISPID_UNKNOWN;\r
373                 return DISP_E_UNKNOWNNAME;\r
374         }\r
375 \r
376         inline STDMETHODIMP CAXWindow::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER* ppMk)\r
377         {\r
378                 UNREFERENCED_PARAMETER(dwAssign);\r
379                 UNREFERENCED_PARAMETER(dwWhichMoniker);\r
380                 UNREFERENCED_PARAMETER(ppMk);\r
381                 return E_NOTIMPL;\r
382         }\r
383 \r
384         inline STDMETHODIMP CAXWindow::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo** pptinfo)\r
385         {\r
386                 UNREFERENCED_PARAMETER(itinfo);\r
387                 UNREFERENCED_PARAMETER(lcid);\r
388                 UNREFERENCED_PARAMETER(pptinfo);\r
389                 return E_NOTIMPL;\r
390         }\r
391 \r
392         inline STDMETHODIMP CAXWindow::GetTypeInfoCount(unsigned int* pctinfo)\r
393         {\r
394                 UNREFERENCED_PARAMETER(pctinfo);\r
395                 return E_NOTIMPL;\r
396         }\r
397 \r
398         inline IUnknown* CAXWindow::GetUnknown()\r
399         {\r
400                 if (!m_pUnk)\r
401                         return NULL;\r
402 \r
403                 m_pUnk->AddRef();\r
404                 return m_pUnk;\r
405         }\r
406 \r
407         inline STDMETHODIMP CAXWindow::GetWindow(HWND* lphwnd)\r
408         {\r
409                 if (!IsWindow(m_hWnd))\r
410                         return S_FALSE;\r
411 \r
412                 *lphwnd = m_hWnd;\r
413                 return S_OK;\r
414         }\r
415 \r
416         inline STDMETHODIMP CAXWindow::GetWindowContext (IOleInPlaceFrame** ppFrame, IOleInPlaceUIWindow** ppIIPUIWin,\r
417                                                                           LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)\r
418         {\r
419                 *ppFrame = (IOleInPlaceFrame*)this;\r
420                 *ppIIPUIWin = NULL;\r
421 \r
422                 RECT rect;\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
428 \r
429                 CopyRect(lprcClipRect, lprcPosRect);\r
430 \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
436 \r
437                 (*ppFrame)->AddRef();\r
438                 return S_OK;\r
439         }\r
440 \r
441         inline STDMETHODIMP CAXWindow::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)\r
442         {\r
443                 UNREFERENCED_PARAMETER(hmenuShared);\r
444                 UNREFERENCED_PARAMETER(lpMenuWidths);\r
445                 return E_NOTIMPL;\r
446         }\r
447 \r
448         inline STDMETHODIMP CAXWindow::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexecinfo, unsigned int* puArgErr)\r
449         {\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
459         }\r
460 \r
461         inline STDMETHODIMP CAXWindow::LockInPlaceActive(BOOL fLock)\r
462         {\r
463                 UNREFERENCED_PARAMETER(fLock);\r
464                 return E_NOTIMPL;\r
465         }\r
466 \r
467         inline STDMETHODIMP CAXWindow::OnControlInfoChanged()\r
468         {\r
469                 return E_NOTIMPL;\r
470         }\r
471 \r
472         inline STDMETHODIMP CAXWindow::OnFocus(BOOL fGotFocus)\r
473         {\r
474                 UNREFERENCED_PARAMETER(fGotFocus);\r
475                 return E_NOTIMPL;\r
476         }\r
477 \r
478         inline STDMETHODIMP CAXWindow::OnInPlaceActivate()\r
479         {\r
480                 return S_OK;\r
481         }\r
482 \r
483         inline STDMETHODIMP CAXWindow::OnInPlaceDeactivate()\r
484         {\r
485                 return S_OK;\r
486         }\r
487 \r
488         inline STDMETHODIMP CAXWindow::OnPosRectChange(LPCRECT lprcPosRect)\r
489         {\r
490                 UNREFERENCED_PARAMETER(lprcPosRect);\r
491                 return S_OK;\r
492         }\r
493 \r
494         inline STDMETHODIMP CAXWindow::OnShowWindow(BOOL fShow)\r
495         {\r
496                 UNREFERENCED_PARAMETER(fShow);\r
497                 return S_OK;\r
498         }\r
499 \r
500         inline STDMETHODIMP CAXWindow::OnUIActivate()\r
501         {\r
502                 return S_OK;\r
503         }\r
504 \r
505         inline STDMETHODIMP CAXWindow::OnUIDeactivate(BOOL fUndoable)\r
506         {\r
507                 UNREFERENCED_PARAMETER(fUndoable);\r
508                 return E_NOTIMPL;\r
509         }\r
510 \r
511         inline STDMETHODIMP CAXWindow::QueryInterface(REFIID riid, void** ppvObject)\r
512         {\r
513                 if (!ppvObject)\r
514                         return E_POINTER;\r
515 \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
527                         *ppvObject = this;\r
528                 else if (IsEqualIID(riid, IID_IDispatch))\r
529                         *ppvObject = (IDispatch*)this;\r
530                 else if (IsEqualIID(riid, IID_IUnknown))\r
531                         *ppvObject = this;\r
532                 else\r
533                 {\r
534                         *ppvObject = NULL;\r
535                         return E_NOINTERFACE;\r
536                 }\r
537 \r
538                 AddRef();\r
539                 return S_OK;\r
540         }\r
541 \r
542         inline STDMETHODIMP_(ULONG) CAXWindow::Release()\r
543         {\r
544                 return --m_cRefs;\r
545         }\r
546 \r
547         inline void CAXWindow::Remove()\r
548         {\r
549                 if (!m_pUnk)\r
550                         return;\r
551 \r
552                 IOleObject* pioo;\r
553                 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);\r
554                 if (SUCCEEDED(hr))\r
555                 {\r
556                         pioo->Close(OLECLOSE_NOSAVE);\r
557                         pioo->SetClientSite(NULL);\r
558                         pioo->Release();\r
559                 }\r
560 \r
561                 IOleInPlaceObject* pipo;\r
562                 hr = m_pUnk->QueryInterface(IID_IOleInPlaceObject, (void**)&pipo);\r
563                 if (SUCCEEDED(hr))\r
564                 {\r
565                         pipo->UIDeactivate();\r
566                         pipo->InPlaceDeactivate();\r
567                         pipo->Release();\r
568                 }\r
569 \r
570         }\r
571 \r
572         inline STDMETHODIMP CAXWindow::RemoveMenus(HMENU hmenuShared)\r
573         {\r
574                 UNREFERENCED_PARAMETER(hmenuShared);\r
575                 return E_NOTIMPL;\r
576         }\r
577 \r
578         inline STDMETHODIMP CAXWindow::RequestBorderSpace(LPCBORDERWIDTHS lpborderwidths)\r
579         {\r
580                 UNREFERENCED_PARAMETER(lpborderwidths);\r
581                 return E_NOTIMPL;\r
582         }\r
583 \r
584         inline STDMETHODIMP CAXWindow::RequestNewObjectLayout()\r
585         {\r
586                 return E_NOTIMPL;\r
587         }\r
588 \r
589         inline STDMETHODIMP CAXWindow::SaveObject()\r
590         {\r
591                 return E_NOTIMPL;\r
592         }\r
593 \r
594         inline STDMETHODIMP CAXWindow::Scroll(SIZE scrollExtent)\r
595         {\r
596                 UNREFERENCED_PARAMETER(scrollExtent);\r
597                 return E_NOTIMPL;\r
598         }\r
599 \r
600         inline STDMETHODIMP CAXWindow::SetActiveObject(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR lpszObjName)\r
601         {\r
602                 UNREFERENCED_PARAMETER(pActiveObject);\r
603                 UNREFERENCED_PARAMETER(lpszObjName);\r
604                 return E_NOTIMPL;\r
605         }\r
606 \r
607         inline STDMETHODIMP CAXWindow::SetBorderSpace(LPCBORDERWIDTHS lpborderwidths)\r
608         {\r
609                 UNREFERENCED_PARAMETER(lpborderwidths);\r
610                 return E_NOTIMPL;\r
611         }\r
612 \r
613         inline void CAXWindow::SetLocation(int x, int y, int width, int height)\r
614         {\r
615                 m_rcControl.SetRect(x, y, x + width, y + height);\r
616 \r
617                 if (!m_pUnk)\r
618                         return;\r
619 \r
620                 IOleInPlaceObject* pipo;\r
621                 HRESULT hr = m_pUnk->QueryInterface(IID_IOleInPlaceObject, (void**)&pipo);\r
622                 if (FAILED(hr))\r
623                         return;\r
624 \r
625                 pipo->SetObjectRects(&m_rcControl, &m_rcControl);\r
626                 pipo->Release();\r
627         }\r
628 \r
629         inline STDMETHODIMP CAXWindow::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)\r
630         {\r
631                 UNREFERENCED_PARAMETER(hmenuShared);\r
632                 UNREFERENCED_PARAMETER(holemenu);\r
633                 UNREFERENCED_PARAMETER(hwndActiveObject);\r
634                 return E_NOTIMPL;\r
635         }\r
636 \r
637         inline void CAXWindow::SetParent(HWND hWndParent)\r
638         {\r
639                 m_hWnd = hWndParent;\r
640         }\r
641 \r
642         inline STDMETHODIMP CAXWindow::SetStatusText(LPCOLESTR pszStatusText)\r
643         {\r
644                 if (NULL == pszStatusText)\r
645                         return E_POINTER;\r
646 \r
647         #ifndef _UNICODE\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
651 \r
652                 if (IsWindow(m_hWndStatus))\r
653                         SendMessage(m_hWndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)status);\r
654         #else\r
655                 if (IsWindow(m_hWndStatus))\r
656                         SendMessage(m_hWndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)pszStatusText);\r
657         #endif\r
658 \r
659                 return (S_OK);\r
660         }\r
661 \r
662         inline void CAXWindow::SetStatusWindow(HWND hWndStatus)\r
663         {\r
664                 m_hWndStatus = hWndStatus;\r
665         }\r
666 \r
667         inline void CAXWindow::SetVisible(BOOL fVisible)\r
668         {\r
669                 if (!m_pUnk)\r
670                         return;\r
671 \r
672                 IOleObject* pioo;\r
673                 HRESULT hr = m_pUnk->QueryInterface(IID_IOleObject, (void**)&pioo);\r
674                 if (FAILED(hr))\r
675                         return;\r
676 \r
677                 if (fVisible)\r
678                 {\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
681                 }\r
682                 else\r
683                         pioo->DoVerb(OLEIVERB_HIDE, NULL, this, 0, m_hWnd, NULL);\r
684 \r
685                 pioo->Release();\r
686         }\r
687 \r
688         inline STDMETHODIMP CAXWindow::ShowObject()\r
689         {\r
690                 return S_OK;\r
691         }\r
692 \r
693         inline STDMETHODIMP CAXWindow::ShowPropertyFrame()\r
694         {\r
695                 return E_NOTIMPL;\r
696         }\r
697 \r
698         inline STDMETHODIMP CAXWindow::TransformCoords(POINTL* pptlHimetric, POINTF* pptfContainer, DWORD dwFlags)\r
699         {\r
700                 UNREFERENCED_PARAMETER(pptlHimetric);\r
701                 UNREFERENCED_PARAMETER(pptfContainer);\r
702                 UNREFERENCED_PARAMETER(dwFlags);\r
703                 return E_NOTIMPL;\r
704         }\r
705 \r
706         inline STDMETHODIMP CAXWindow::TranslateAccelerator(LPMSG lpmsg, WORD wID)\r
707         {\r
708                 UNREFERENCED_PARAMETER(lpmsg);\r
709                 UNREFERENCED_PARAMETER(wID);\r
710                 return S_OK;\r
711         }\r
712 \r
713         inline STDMETHODIMP CAXWindow::TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers)\r
714         {\r
715                 UNREFERENCED_PARAMETER(pMsg);\r
716                 UNREFERENCED_PARAMETER(grfModifiers);\r
717                 return S_FALSE;\r
718         }\r
719 \r
720         inline void CAXWindow::TranslateKey(MSG msg)\r
721         {\r
722                 if (!m_pUnk)\r
723                         return;\r
724 \r
725                 IOleInPlaceActiveObject* pao;\r
726                 HRESULT hr = m_pUnk->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pao);\r
727                 if (FAILED(hr))\r
728                         return;\r
729 \r
730                 pao->TranslateAccelerator(&msg);\r
731                 pao->Release();\r
732         }\r
733 \r
734 \r
735         ////////////////////////////////////////\r
736         // Definitions for the CWebBrowser class\r
737         //\r
738         inline CWebBrowser::CWebBrowser() : m_pIWebBrowser2(0)\r
739         {\r
740                 OleInitialize(NULL);\r
741         }\r
742 \r
743         inline CWebBrowser::~CWebBrowser()\r
744         {\r
745                 if (m_pIWebBrowser2)\r
746                 {\r
747                         m_pIWebBrowser2->Stop();\r
748                         m_pIWebBrowser2->Release();\r
749                 }\r
750 \r
751                 OleUninitialize();\r
752         }\r
753 \r
754         inline void CWebBrowser::AddWebBrowserControl()\r
755         {\r
756                 GetAXWindow().CreateControl(CLSID_WebBrowser);\r
757                 GetAXWindow().SetParent(m_hWnd);\r
758                 GetAXWindow().SetVisible(TRUE);\r
759                 GetAXWindow().Activate(TRUE);\r
760 \r
761                 IUnknown* pUnk = GetAXWindow().GetUnknown();\r
762                 if(pUnk)\r
763                 {\r
764                         // Store the pointer to the WebBrowser control\r
765                         HRESULT hr = pUnk->QueryInterface(IID_IWebBrowser2, (void**)&m_pIWebBrowser2);\r
766                         pUnk->Release();\r
767 \r
768                         // Navigate to an empty page\r
769                         if (SUCCEEDED(hr))\r
770                         {\r
771                                 m_pIWebBrowser2->Navigate((OLECHAR*)L"about:blank", 0, 0, 0, 0);\r
772                         }\r
773                 }\r
774         }\r
775 \r
776         inline void CWebBrowser::OnCreate()\r
777         {\r
778                 AddWebBrowserControl();\r
779         }\r
780 \r
781         inline void CWebBrowser::OnSize(int width, int height)\r
782         {\r
783                 // position the container\r
784                 GetAXWindow().SetLocation(0, 0, width, height);\r
785         }\r
786 \r
787         inline LRESULT CWebBrowser::WndProcDefault(UINT uMsg, WPARAM wParam, LPARAM lParam)\r
788         {\r
789                 switch(uMsg)\r
790                 {\r
791                 case WM_SIZE:\r
792                         OnSize(LOWORD(lParam), HIWORD(lParam));\r
793                         break;\r
794                 case WM_DESTROY:\r
795                         GetAXWindow().Remove();\r
796                         break;\r
797                 }\r
798 \r
799                 return CWnd::WndProcDefault(uMsg, wParam, lParam);\r
800         }\r
801 \r
802         inline LPDISPATCH CWebBrowser::GetApplication() const\r
803         // Retrieves the automation object for the application that is hosting the WebBrowser Control.\r
804         {\r
805                 LPDISPATCH Value;\r
806                 GetIWebBrowser2()->get_Application(&Value);\r
807                 return Value;\r
808         }\r
809 \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
812         {\r
813                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
814                 GetIWebBrowser2()->get_Busy(&bValue);\r
815                 return (BOOL)bValue;\r
816         }\r
817 \r
818         inline LPDISPATCH CWebBrowser::GetContainer() const\r
819         // Retrieves an object reference to a container.\r
820         {\r
821                 LPDISPATCH Value;\r
822                 GetIWebBrowser2()->get_Container(&Value);\r
823                 return Value;\r
824         }\r
825 \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
828         {\r
829                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
830                 GetIWebBrowser2()->get_FullScreen(&bValue);\r
831                 return (BOOL)bValue;\r
832         }\r
833 \r
834         inline long CWebBrowser::GetHeight() const\r
835         // Retrieves the height of the object.\r
836         {\r
837                 long lValue;\r
838                 GetIWebBrowser2()->get_Height(&lValue);\r
839                 return lValue;\r
840         }\r
841 \r
842         inline long CWebBrowser::GetLeft() const\r
843         // Retrieves the coordinate of the left edge of the object.\r
844         {\r
845                 long lValue;\r
846                 GetIWebBrowser2()->get_Left(&lValue);\r
847                 return lValue;\r
848         }\r
849 \r
850         inline CString CWebBrowser::GetLocationName() const\r
851         // Retrieves the path or title of the resource that is currently displayed.\r
852         {\r
853                 BSTR bstr;\r
854                 GetIWebBrowser2()->get_LocationName(&bstr);\r
855                 CString str(bstr);\r
856                 SysFreeString(bstr);\r
857                 return str;\r
858         }\r
859 \r
860         inline CString CWebBrowser::GetLocationURL() const\r
861         // Retrieves the URL of the resource that is currently displayed.\r
862         {\r
863                 BSTR bstr;\r
864                 GetIWebBrowser2()->get_LocationURL(&bstr);\r
865                 CString str(bstr);\r
866                 SysFreeString(bstr);\r
867                 return str;\r
868         }\r
869 \r
870         inline BOOL CWebBrowser::GetOffline() const\r
871         // Retrieves a value that indicates whether the object is operating in offline mode.\r
872         {\r
873                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
874                 GetIWebBrowser2()->get_Offline(&bValue);\r
875                 return (BOOL)bValue;\r
876         }\r
877 \r
878         inline READYSTATE CWebBrowser::GetReadyState() const\r
879         // Retrieves the ready state of the object.\r
880         {\r
881                 READYSTATE rsValue;\r
882                 GetIWebBrowser2()->get_ReadyState(&rsValue);\r
883                 return rsValue;\r
884         }\r
885 \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
888         {\r
889                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
890 #if defined(__BORLANDC__) && (__BORLANDC__ < 0x600)\r
891                 GetIWebBrowser2()->get_RegisterAsBrowser(&bValue);\r
892 #endif\r
893                 return (BOOL)bValue;\r
894         }\r
895 \r
896         inline BOOL CWebBrowser::GetTheaterMode() const\r
897         // Retrieves the theater mode state of the object.\r
898         {\r
899                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
900                 GetIWebBrowser2()->get_TheaterMode(&bValue);\r
901                 return (BOOL)bValue;\r
902         }\r
903 \r
904         inline long CWebBrowser::GetTop() const\r
905         // Retrieves the coordinate of the top edge of the object.\r
906         {\r
907                 long lValue;\r
908                 GetIWebBrowser2()->get_Top(&lValue);\r
909                 return lValue;\r
910         }\r
911 \r
912         inline BOOL CWebBrowser::GetTopLevelContainer() const\r
913         //Retrieves a value that indicates whether the object is a top-level container.\r
914         {\r
915                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
916                 GetIWebBrowser2()->get_TopLevelContainer(&bValue);\r
917                 return (BOOL)bValue;\r
918         }\r
919 \r
920         inline CString CWebBrowser::GetType() const\r
921         // Retrieves the user type name of the contained document object.\r
922         {\r
923                 BSTR bString;\r
924                 GetIWebBrowser2()->get_Type(&bString);\r
925                 CString str(bString);\r
926                 SysFreeString(bString);\r
927                 return str;\r
928         }\r
929 \r
930         inline BOOL CWebBrowser::GetVisible() const\r
931         // Retrieves a value that indicates whether the object is visible or hidden.\r
932         {\r
933                 VARIANT_BOOL bValue = VARIANT_FALSE;\r
934                 GetIWebBrowser2()->get_Visible(&bValue);\r
935                 return (BOOL)bValue;\r
936         }\r
937 \r
938         inline long CWebBrowser::GetWidth() const\r
939         // Retrieves the width of the object.\r
940         {\r
941                 long lValue;\r
942                 GetIWebBrowser2()->get_Width(&lValue);\r
943                 return lValue;\r
944         }\r
945 \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
948         {\r
949                 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;\r
950                 GetIWebBrowser2()->put_FullScreen(vBool);\r
951         }\r
952 \r
953         inline void CWebBrowser::SetHeight(long nNewValue)\r
954         // Sets the height of the object.\r
955         {\r
956                 GetIWebBrowser2()->put_Height(nNewValue);\r
957         }\r
958 \r
959         inline void CWebBrowser::SetLeft(long nNewValue)\r
960         // Sets the coordinate of the left edge of the object.\r
961         {\r
962                 GetIWebBrowser2()->put_Left(nNewValue);\r
963         }\r
964 \r
965         inline void CWebBrowser::SetOffline(BOOL bNewValue)\r
966         // Sets a value that indicates whether the object is operating in offline mode.\r
967         {\r
968                 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;\r
969                 GetIWebBrowser2()->put_Offline(vBool);\r
970         }\r
971 \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
974         {\r
975                 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;\r
976                 GetIWebBrowser2()->put_RegisterAsBrowser(vBool);\r
977         }\r
978 \r
979         inline void CWebBrowser::SetTheaterMode(BOOL bNewValue)\r
980         // Sets the theatre mode state of the object.\r
981         {\r
982                 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;\r
983                 GetIWebBrowser2()->put_TheaterMode(vBool);\r
984         }\r
985 \r
986         inline void CWebBrowser::SetTop(long nNewValue)\r
987         // Sets the coordinate of the top edge of the object.\r
988         {\r
989                 GetIWebBrowser2()->put_Top(nNewValue);\r
990         }\r
991 \r
992         inline void CWebBrowser::SetVisible(BOOL bNewValue)\r
993         // Sets a value that indicates whether the object is visible or hidden.\r
994         {\r
995                 VARIANT_BOOL vBool = bNewValue? VARIANT_TRUE : VARIANT_FALSE;\r
996                 GetIWebBrowser2()->put_Visible(vBool);\r
997         }\r
998 \r
999         inline void CWebBrowser::SetWidth(long nNewValue)\r
1000         // Sets the width of the object.\r
1001         {\r
1002                 GetIWebBrowser2()->put_Width(nNewValue);\r
1003         }\r
1004 \r
1005         inline void CWebBrowser::ExecWB(OLECMDID cmdID, OLECMDEXECOPT cmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut)\r
1006         // Executes a command using the IOleCommandTarget interface.\r
1007         {\r
1008                 GetIWebBrowser2()->ExecWB(cmdID, cmdexecopt, pvaIn, pvaOut);\r
1009         }\r
1010 \r
1011         inline BOOL CWebBrowser::GetProperty(LPCTSTR pszProperty, CString& strValue)\r
1012         // Gets the value associated with the specified property name.\r
1013         {\r
1014                 VARIANT v;\r
1015                 HRESULT hResult = GetIWebBrowser2()->GetProperty(T2BSTR(pszProperty), &v);\r
1016                 if (v.vt == VT_EMPTY)\r
1017                         strValue.Empty();\r
1018                 else\r
1019                         strValue = BSTR2T(v.bstrVal);\r
1020 \r
1021         return (hResult == S_OK);\r
1022         }\r
1023 \r
1024         inline VARIANT CWebBrowser::GetProperty( LPCTSTR pszProperty )\r
1025         // Gets the value associated with the specified property name.\r
1026         {\r
1027                 VARIANT v;\r
1028                 GetIWebBrowser2()->GetProperty( T2BSTR(pszProperty), &v );\r
1029                 return v;\r
1030         }\r
1031 \r
1032         inline void CWebBrowser::GoBack()\r
1033         // Navigates backward one item in the history list.\r
1034         {\r
1035                 GetIWebBrowser2()->GoBack();\r
1036         }\r
1037 \r
1038         inline void CWebBrowser::GoForward()\r
1039         // Navigates forward one item in the history list.\r
1040         {\r
1041                 GetIWebBrowser2()->GoForward();\r
1042         }\r
1043 \r
1044         inline void CWebBrowser::GoHome()\r
1045         // Navigates to the current home or start page.\r
1046         {\r
1047                 GetIWebBrowser2()->GoHome();\r
1048         }\r
1049 \r
1050         inline void CWebBrowser::GoSearch()\r
1051         // Navigates to the current search page.\r
1052         {\r
1053                 GetIWebBrowser2()->GoSearch();\r
1054         }\r
1055 \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
1059         {\r
1060                 VARIANT Flags;\r
1061                 Flags.vt = VT_I4;\r
1062                 Flags.lVal = dwFlags;\r
1063 \r
1064                 VARIANT TargetFrameName;\r
1065                 TargetFrameName.vt = VT_BSTR;\r
1066                 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));\r
1067 \r
1068                 SAFEARRAY* psa = SafeArrayCreateVector(VT_UI1, 0, dwPostDataLen);\r
1069                 CopyMemory(psa->pvData, pvPostData, dwPostDataLen);\r
1070                 VARIANT PostData;\r
1071                 PostData.vt = VT_ARRAY|VT_UI1;\r
1072                 PostData.parray = psa;\r
1073 \r
1074                 VARIANT Headers;\r
1075                 Headers.vt = VT_BSTR;\r
1076                 Headers.bstrVal = SysAllocString(T2W(pszHeaders));\r
1077                 BSTR url = SysAllocString(T2W(pszURL));\r
1078 \r
1079                 GetIWebBrowser2()->Navigate(url, &Flags, &TargetFrameName, &PostData, &Headers);\r
1080 \r
1081                 VariantClear(&Flags);\r
1082                 VariantClear(&TargetFrameName);\r
1083                 VariantClear(&PostData);\r
1084                 VariantClear(&Headers);\r
1085         }\r
1086 \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
1089         {\r
1090                 UINT cb = GetPidlLength(pIDL);\r
1091                 LPSAFEARRAY psa = SafeArrayCreateVector(VT_UI1, 0, cb);\r
1092                 VARIANT PIDL;\r
1093                 PIDL.vt = VT_ARRAY|VT_UI1;\r
1094                 PIDL.parray = psa;\r
1095                 CopyMemory(psa->pvData, pIDL, cb);\r
1096 \r
1097                 VARIANT Flags;\r
1098                 Flags.vt = VT_I4;\r
1099                 Flags.lVal = dwFlags;\r
1100 \r
1101                 VARIANT TargetFrameName;\r
1102                 TargetFrameName.vt = VT_BSTR;\r
1103                 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));\r
1104 \r
1105                 GetIWebBrowser2()->Navigate2(&PIDL, &Flags, &TargetFrameName, 0, 0);\r
1106 \r
1107                 VariantClear(&PIDL);\r
1108                 VariantClear(&Flags);\r
1109                 VariantClear(&TargetFrameName);\r
1110         }\r
1111 \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
1115         {\r
1116                 VARIANT URL;\r
1117                 URL.vt = VT_BSTR;\r
1118                 URL.bstrVal = SysAllocString(T2W(pszURL));\r
1119 \r
1120                 VARIANT Flags;\r
1121                 Flags.vt = VT_I4;\r
1122                 Flags.lVal = dwFlags;\r
1123 \r
1124                 VARIANT TargetFrameName;\r
1125                 TargetFrameName.vt = VT_BSTR;\r
1126                 TargetFrameName.bstrVal = SysAllocString(T2W(pszTargetFrameName));\r
1127 \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
1131                 VARIANT PostData;\r
1132                 PostData.vt = VT_ARRAY|VT_UI1;\r
1133                 PostData.parray = psa;\r
1134 \r
1135                 VARIANT Headers;\r
1136                 Headers.vt = VT_BSTR;\r
1137                 Headers.bstrVal = SysAllocString(T2W(pszHeaders));\r
1138 \r
1139                 GetIWebBrowser2()->Navigate2(&URL, &Flags, &TargetFrameName, &PostData, &Headers);\r
1140 \r
1141                 VariantClear(&URL);\r
1142                 VariantClear(&Flags);\r
1143                 VariantClear(&TargetFrameName);\r
1144                 VariantClear(&PostData);\r
1145                 VariantClear(&Headers);\r
1146         }\r
1147 \r
1148         inline void CWebBrowser::PutProperty(LPCTSTR pszProperty, const VARIANT& vtValue)\r
1149         // Sets the value of a property associated with the object.\r
1150         {\r
1151                 GetIWebBrowser2()->PutProperty(T2BSTR(pszProperty), vtValue);\r
1152         }\r
1153 \r
1154         inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, double dValue)\r
1155         // Sets the value of a property associated with the object.\r
1156         {\r
1157                 VARIANT v;\r
1158                 v.vt = VT_I4;\r
1159                 v.dblVal = dValue;\r
1160                 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);\r
1161                 VariantClear(&v);\r
1162         }\r
1163 \r
1164         inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, long lValue)\r
1165         // Sets the value of a property associated with the object.\r
1166         {\r
1167                 VARIANT v;\r
1168                 v.vt = VT_I4;\r
1169                 v.lVal= lValue;\r
1170                 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);\r
1171                 VariantClear(&v);\r
1172         }\r
1173 \r
1174         inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, LPCTSTR lpszValue)\r
1175         // Sets the value of a property associated with the object.\r
1176         {\r
1177                 VARIANT v;\r
1178                 v.vt = VT_BSTR;\r
1179                 v.bstrVal= SysAllocString(T2W(lpszValue));\r
1180                 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);\r
1181                 VariantClear(&v);\r
1182         }\r
1183 \r
1184         inline void CWebBrowser::PutProperty(LPCTSTR pszPropertyName, short nValue)\r
1185         // Sets the value of a property associated with the object.\r
1186         {\r
1187                 VARIANT v;\r
1188                 v.vt = VT_I4;\r
1189                 v.iVal = nValue;\r
1190                 GetIWebBrowser2()->PutProperty(T2BSTR(pszPropertyName), v);\r
1191                 VariantClear(&v);\r
1192         }\r
1193 \r
1194         inline void CWebBrowser::Refresh()\r
1195         // Reloads the file that is currently displayed in the object.\r
1196         {\r
1197                 GetIWebBrowser2()->Refresh();\r
1198         }\r
1199 \r
1200         inline void CWebBrowser::Refresh2(int nLevel)\r
1201         // Reloads the file that is currently displayed with the specified refresh level.\r
1202         {\r
1203                 VARIANT v;\r
1204                 v.vt = VT_I4;\r
1205                 v.intVal = nLevel;\r
1206                 GetIWebBrowser2()->Refresh2(&v);\r
1207                 VariantClear(&v);\r
1208         }\r
1209 \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
1212         {\r
1213                 GetIWebBrowser2()->Stop();\r
1214         }\r
1215 \r
1216 \r
1217 }\r
1218 \r
1219 #endif  // _WIN32XX_WEBBROWSER_H_\r
1220 \r

UCC git Repository :: git.ucc.asn.au