home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / activexcontrol / webimage / wimgctl.h < prev    next >
C/C++ Source or Header  |  1997-10-09  |  5KB  |  154 lines

  1. //=--------------------------------------------------------------------------=
  2. // WImgCtl.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 - 1997 Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // class declaration for the WebImage control.
  13. //
  14. #ifndef _WEBIMAGECONTROL_H_
  15.  
  16. #include "IPServer.H"
  17. #include "CtrlObj.H"
  18. #include "Internet.h"
  19. #include "WImgInterfaces.H"
  20. #include "Dispids.H"
  21.  
  22.  
  23. #include "DibCls.H"
  24.  
  25. typedef struct tagWEBIMAGECTLSTATE {
  26.  
  27.     // TOOD: put state variables here, and probably get rid of fGarbage, unless
  28.     // you have a real need for it
  29.     //
  30.     VARIANT_BOOL fGarbage;
  31.  
  32. } WEBIMAGECTLSTATE;
  33.  
  34. //=--------------------------------------------------------------------------=
  35. // CWebImageControl
  36. //=--------------------------------------------------------------------------=
  37. // our control.
  38. //
  39. class CWebImageControl :       public CInternetControl, 
  40.                                                                         public IWebImage, 
  41.                                     public ISupportErrorInfo {
  42.  
  43.   public:
  44.     // IUnknown methods
  45.     //
  46.     DECLARE_STANDARD_UNKNOWN();
  47.  
  48.     // IDispatch methods
  49.     //
  50.     DECLARE_STANDARD_DISPATCH();
  51.  
  52.     // ISupportErrorInfo methods
  53.     //
  54.     DECLARE_STANDARD_SUPPORTERRORINFO();
  55.  
  56.     // IWebImage methods
  57.     //
  58.     // TODO: copy over the method declarations from WebImageInterfaces.H
  59.     //       don't forget to remove the PURE from them.
  60.     //
  61.     STDMETHOD(get_Image)(THIS_ BSTR FAR* path) ;
  62.     STDMETHOD(put_Image)(THIS_ BSTR path) ;
  63.     STDMETHOD_(void, AboutBox)(THIS) ;
  64.     STDMETHOD(Scramble)(THIS) ;
  65.  
  66.     // OLE Control stuff follows:
  67.     //
  68.     CWebImageControl(IUnknown *pUnkOuter);
  69.     virtual ~CWebImageControl();
  70.  
  71.     // static creation function.  all controls must have one of these!
  72.     //
  73.     static IUnknown *Create(IUnknown *);
  74.  
  75.   private:
  76.     // overridables that the control must implement.
  77.     //
  78.     STDMETHOD(LoadBinaryState)(IStream *pStream);
  79.     STDMETHOD(SaveBinaryState)(IStream *pStream);
  80.     STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
  81.     STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault);
  82.     STDMETHOD(OnDraw)(DWORD dvAspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize);
  83.     virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
  84.     virtual BOOL    RegisterClassData(void);
  85.  
  86.     virtual HRESULT InternalQueryInterface(REFIID, void **);
  87.     virtual void    BeforeCreateWindow(void);
  88.     
  89.     virtual BOOL    AfterCreateWindow(void);
  90.  
  91.     //    Internet specific callbacks:
  92.     //
  93.     ///    OnData is called asynchronously as data for an object or property arrives...
  94.     virtual HRESULT OnData( DISPID id, DWORD grfBSCF,IStream * bitstrm, DWORD amount );
  95.  
  96.     //    OnProgess is called to allow you to present progess indication UI
  97.     virtual HRESULT OnProgress( DISPID, ULONG progress, ULONG themax, ULONG, LPCWSTR);
  98.  
  99.  
  100.     // private state information.
  101.     //
  102.  
  103.     HRESULT SetBmpPath(const char *psz);
  104.     HRESULT SetBmpPath(IStream *);
  105.     HRESULT UpdateImage();
  106.  
  107.     enum bmpDownloadStates
  108.     {
  109.         bdsNoBitsYet,
  110.         bdsGotFileHeader,
  111.         bdsGotBitmapInfo,
  112.         bdsGettingBits,
  113.         bdsBitsAreDone
  114.     };
  115.  
  116.  
  117.     HDC                    m_dc;
  118.     bmpDownloadStates    m_state;
  119.     CDibFile *            m_dibFile;
  120.     CDibSection *        m_dib;
  121.  
  122.     // Actual properties
  123.     char *                m_bmpPath;
  124.  
  125. };
  126.  
  127.  
  128. // TODO: if you have an array of verbs, then add an extern here with the name
  129. //       of it, so that you can include it in the DEFINE_CONTROLOBJECT.
  130. //       ie.  extern VERBINFO m_WebImageCustomVerbs [];
  131. //
  132. extern const GUID    *rgWebImagePropPages [];
  133. DEFINE_CONTROLOBJECT(WebImage,
  134.     &CLSID_WebImage,
  135.     "WebImageCtl",
  136.     CWebImageControl::Create,
  137.     1,
  138.     &IID_IWebImage,
  139.     "WebImage.HLP",
  140.     &DIID_DWebImageEvents,
  141.     OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|OLEMISC_RECOMPOSEONRESIZE|OLEMISC_CANTLINKINSIDE|OLEMISC_INSIDEOUT,
  142.     0,
  143.     RESID_TOOLBOX_BITMAP,
  144.     "WebImageWndClass",
  145.     1,
  146.     rgWebImagePropPages,
  147.     0,
  148.     NULL);
  149.  
  150.  
  151.  
  152. #define _WEBIMAGECONTROL_H_
  153. #endif // _WEBIMAGECONTROL_H_
  154.