webapp.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 3k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. //////////////////////////////////////////////////////////////////////////
  2. //
  3. //  webapp.h
  4. //
  5. //      The purpose of this application is to demonstrate how a C++
  6. //      application can host IE4, and manipulate the OC vtable.
  7. //
  8. //      This file contains the specification of the WebApp class.
  9. //
  10. //  (C) Copyright 1997 by Microsoft Corporation. All rights reserved.
  11. //
  12. //////////////////////////////////////////////////////////////////////////
  13. #ifndef _WEBAPP_H_
  14. #define _WEBAPP_H_
  15. #include <exdisp.h>
  16. #include <mshtml.h>
  17. #include "container.h"
  18. #include "inidata.h"
  19. class CEventSink;
  20. class CWebApp
  21. {
  22.     private:
  23.         HINSTANCE       m_hInstance;        // application instance
  24.         HWND            m_hwnd;             // window handle
  25.         CContainer      *m_pContainer;      // container object
  26.         IWebBrowser2    *m_pweb;            // IE4 IWebBrowser interface pointer
  27.         DWORD           m_eventCookie;      // unique id for event wiring
  28.         CEventSink      *m_pEvent;          // event object
  29.         CIniData        m_IniData;          // info from ini and registry about display items
  30.         bool            m_bVirgin;          // true until after we inject the menu items.  Prevents multiple injection.
  31.         bool            m_bUseDA;           // true if we should use DirectAnimation.  This will be set to false if you
  32.                                             // have a 16 color (or less) display (or if the no-animations poicy is set?).
  33.     public:
  34.         CWebApp();
  35.         void Register(HINSTANCE hInstance);
  36.         void InitializeData();
  37.         void Create();
  38.         void MessageLoop();
  39.     public:
  40.         // Event callbacks
  41.         void eventBeforeNavigate2(VARIANT* URL, VARIANT_BOOL* Cancel);
  42.         void eventDocumentComplete(VARIANT* URL);
  43.     private:
  44.         static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  45.         // Window Messages
  46.         void OnCreate(HWND hwnd);
  47.         void OnDestroy();
  48.         void OnSize(int width, int height);
  49.         void OnKeyDown(UINT msg, WPARAM wParam, LPARAM lParam);
  50.         void OnSetFocus(HWND hwndLose);
  51.         // Calls to IE4 WebOC
  52.         void Navigate(BSTR url);
  53.         // Private helper APIs
  54.         IConnectionPoint * GetConnectionPoint(REFIID riid);
  55.         void ConnectEvents();
  56.         void DisconnectEvents();
  57.         HRESULT FindIDInDoc(LPCTSTR szItemName, IHTMLElement ** ppElement );
  58.         HRESULT SetBaseDirHack();
  59.         void SetRunState();
  60. };
  61. class CEventSink : public IDispatch
  62. {
  63.     private:
  64.         ULONG       m_cRefs;        // ref count
  65.         CWebApp     *m_pApp;       // reference to web app object
  66.     public:
  67.         CEventSink(CWebApp *webapp);
  68.     public:
  69.         // *** IUnknown Methods ***
  70.         STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  71.         STDMETHOD_(ULONG, AddRef)(void);
  72.         STDMETHOD_(ULONG, Release)(void);
  73.         // *** IDispatch Methods ***
  74.         STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  75.         STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  76.         STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  77.         STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  78. };
  79. #endif