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 / basectl / card / cardctl.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  4KB  |  146 lines

  1. //=--------------------------------------------------------------------------=
  2. // CardCtl.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 Card control.
  13. //
  14. #ifndef _CARDCONTROL_H_
  15.  
  16. #include "IPServer.H"
  17. #include "CtrlObj.H"
  18. #include "CardInterfaces.h"
  19. #include "Dispids.H"
  20.  
  21. //=--------------------------------------------------------------------------=
  22. // CCARDControl
  23. //=--------------------------------------------------------------------------=
  24. // our control.
  25. //
  26. class CCardControl :       public COleControl, 
  27.                            public ICard, 
  28.                  public ISupportErrorInfo {
  29.  
  30.   public:
  31.     // IUnknown methods
  32.     //
  33.     DECLARE_STANDARD_UNKNOWN();
  34.  
  35.     // IDispatch methods
  36.     //
  37.     DECLARE_STANDARD_DISPATCH();
  38.  
  39.     // ISupportErrorInfo methods
  40.     //
  41.     DECLARE_STANDARD_SUPPORTERRORINFO();
  42.  
  43.     // ICARD methods
  44.     //
  45.     // TODO: copy over the method declarations from CARDInterfaces.H
  46.     //       don't forget to remove the PURE from them.
  47.     //
  48.     STDMETHOD(get_Number)(THIS_ enumCardNumber * number) ;
  49.     STDMETHOD(put_Number)(THIS_ enumCardNumber number) ;
  50.     STDMETHOD(get_Suite)(THIS_ enumCardSuite * suite) ;
  51.     STDMETHOD(put_Suite)(THIS_ enumCardSuite suite) ;
  52.     STDMETHOD(get_Invert)(THIS_ VARIANT_BOOL * invert) ;
  53.     STDMETHOD(put_Invert)(THIS_ VARIANT_BOOL invert) ;
  54.     STDMETHOD(get_CardAlignment)(THIS_ enumCardAlignment * align) ;
  55.     STDMETHOD(put_CardAlignment)(THIS_ enumCardAlignment align) ;
  56.     STDMETHOD_(void, AboutBox)(THIS) ;
  57.  
  58.     // OLE Control stuff follows:
  59.     //
  60.     CCardControl(IUnknown *pUnkOuter);
  61.     virtual ~CCardControl();
  62.  
  63.     // static creation function.  all controls must have one of these!
  64.     //
  65.     static IUnknown *Create(IUnknown *);
  66.  
  67.   private:
  68.     // overridables that the control must implement.
  69.     //
  70.     STDMETHOD(LoadBinaryState)(IStream *pStream);
  71.     STDMETHOD(SaveBinaryState)(IStream *pStream);
  72.     STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
  73.     STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault);
  74.     STDMETHOD(OnDraw)(DWORD dvaspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize);
  75.     virtual LRESULT WindowProc( UINT msg, WPARAM wParam, LPARAM lParam);
  76.     virtual BOOL    RegisterClassData(void);
  77.  
  78.     virtual HRESULT InternalQueryInterface(REFIID, void **);
  79.  
  80.     // private state information.
  81.     //
  82.     HRESULT DrawMe( HDC hdcMem );
  83.     void DrawBack(void);
  84.  
  85.     // Actual properties
  86.     enumCardNumber    m_number;
  87. #define DefaultNumber CardAce
  88.     void ValidateNumber() 
  89.     {
  90.         if( m_number < CardAce ) m_number = CardAce;
  91.         if( m_number > CardJoker ) m_number = CardJoker;
  92.     }
  93.  
  94.     enumCardSuite m_suite;
  95. #define DefaultSuite CardBlank
  96.     void ValidateSuite()
  97.     {
  98.         if( m_suite > CardDiamond ) m_suite = CardDiamond;
  99.     }
  100.  
  101.     VARIANT_BOOL m_invert;
  102.     enum { DefaultInvert = VARIANT_FALSE };
  103.  
  104.     enumCardAlignment   m_cardalignment;
  105. #define DefaultCardAlignment CardCenter
  106.     void ValidateCardAlignment()
  107.     {
  108.         if( m_cardalignment < CardTopLeft ) m_cardalignment = CardTopLeft;
  109.         if( m_cardalignment > CardStretch ) m_cardalignment = CardStretch;
  110.     }
  111.  
  112.     HBRUSH BackBrush;
  113. };
  114.  
  115.  
  116. // TODO: if you have an array of verbs, then add an extern here with the name
  117. //       of it, so that you can include it in the DEFINE_CONTROLOBJECT.
  118. //       ie.  extern VERBINFO m_CARDCustomVerbs [];
  119. //
  120. extern const GUID    *rgCardPropPages [];
  121. DEFINE_WINDOWLESSCONTROLOBJECT(Card,
  122.     &CLSID_Card,
  123.     "ActiveXCardControl",
  124.     CCardControl::Create,
  125.     1,
  126.     &IID_ICard,
  127.     "CARD.HLP",
  128.     &DIID_DCardEvents,
  129.     OLEMISC_SETCLIENTSITEFIRST|OLEMISC_ACTIVATEWHENVISIBLE|
  130. OLEMISC_RECOMPOSEONRESIZE|OLEMISC_CANTLINKINSIDE|OLEMISC_INSIDEOUT,
  131.     FALSE,
  132.     FALSE,
  133.     RESID_TOOLBOX_BITMAP,
  134.     "CARDWndClass",
  135.     1,
  136.     rgCardPropPages,
  137.     0,
  138.     NULL);
  139.  
  140.  
  141.  
  142. #define _CARDCONTROL_H_
  143. #endif // _CARDCONTROL_H_
  144.  
  145.  
  146.