My Project
WebBrowser.h
1 #pragma once
2 //#include <Windows.h>
3 //#include <crtdbg.h>
4 #include "OleIdl.h"
5 #include <string>
6 #include "IBrowserMsgListener.h"
7 #define NOTIMPLEMENTED _ASSERT(0); return(E_NOTIMPL)
8 
9 namespace ParaEngine
10 {
11  class LauncherApp;
12  class WBClientSite;
13 
14  class WebBrowser:public IDispatch
15  {
16  public:
17  WebBrowser(HWND hParentWnd,IBrowserMsgListener* pApp);
18  ~WebBrowser();
19 
20  static void RegisterDefaultBrowserWnd(HINSTANCE instance);
21 
22  void Cleanup();
23  void UnembedBrowser();
24  void ShowHTMLPage(LPCTSTR url);
25  HWND GetHWND(){return m_hWnd;}
26  void ChangeWindowSize(int nWidth, int nHeight);
27  void Refresh();
28  void GoBack();
29  void GoForward();
30  void Stop();
31 
33  std::string get_LocationURL();
34 
35  // The class name of our Window to host the browser. It can be anything of your choosing.
36  static WCHAR* g_BrowserClassName;
37 
38  //IDispatch Members
39  STDMETHODIMP Invoke (DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
40  DISPPARAMS* pDispParams,VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr);
41 
42  virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID *ppvObj)
43  {
44  HRESULT ret = S_OK;
45  if(riid == IID_IUnknown)
46  *ppvObj = static_cast<IUnknown *>(this);
47  else if(riid == IID_IDispatch)
48  *ppvObj = static_cast<IDispatch *>(this);
49  else
50  *ppvObj = 0, ret = E_NOINTERFACE;;
51  return ret;
52  }
53 
54  virtual ULONG STDMETHODCALLTYPE AddRef(void){ return 1; }
55  virtual ULONG STDMETHODCALLTYPE Release(void){ return 1; }
56  virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(unsigned int FAR* pctinfo){ return E_NOTIMPL; }
57  virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo){ return E_NOTIMPL; }
58  virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId){ return E_NOTIMPL; }
59 
61  bool FindText(const std::string& sFindText);
62 
64  void WriteContent(const std::string& sContent);
65 
67  void GetContent(std::string& sContent);
68 
69  static LRESULT CALLBACK browserWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
70  private:
71  IOleObject* m_pBrowserObj;
72  HWND m_hWnd;
73  bool m_ignoreDownLoadComplete;
74  bool m_navErr;
75  IBrowserMsgListener* m_pMsgListener;
76  WBClientSite* m_pClientSite;
77  };
78 }
bool FindText(const std::string &sFindText)
find a given text
Definition: WebBrowser.cpp:347
Definition: IBrowserMsgListener.h:9
different physics engine has different winding order.
Definition: EventBinding.h:32
void WriteContent(const std::string &sContent)
write user specified content to web browser
Definition: WebBrowser.cpp:392
Definition: WBClientSite.h:9
std::string get_LocationURL()
get the current location url
Definition: WebBrowser.cpp:291
void GetContent(std::string &sContent)
get the current html.body content
Definition: WebBrowser.cpp:465
Definition: WebBrowser.h:14