SQUARE.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

  1. /*
  2.  * SQUARE.H
  3.  * Square Automation Object Chapter 15
  4.  *
  5.  * Definitions, classes, and prototypes for an EXE that
  6.  * provides Square objects to automation controllers
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14. #ifndef _SQUARE_H_
  15. #define _SQUARE_H_
  16. //Get the object definitions
  17. #define INC_AUTOMATION
  18. #define CHAPTER15
  19. #define GUIDS_FROM_TYPELIB
  20. #include <inole.h>
  21. #include <math.h>
  22. #include "isquare.h"
  23. LRESULT APIENTRY MainWndProc(HWND, UINT, WPARAM, LPARAM);
  24. class CApp
  25.     {
  26.     friend LRESULT APIENTRY MainWndProc(HWND, UINT, WPARAM, LPARAM);
  27.     protected:
  28.         HINSTANCE       m_hInst;            //WinMain parameters
  29.         HINSTANCE       m_hInstPrev;
  30.         LPSTR           m_pszCmdLine;
  31.         UINT            m_nCmdShow;
  32.         BOOL            m_fInitialized;     //Did CoInitialize work?
  33.         LPCLASSFACTORY  m_pIClassFactory;   //Our class factory
  34.         DWORD           m_dwRegCO;          //Registration key
  35.     public:
  36.         CApp(HINSTANCE, HINSTANCE, LPSTR, UINT);
  37.         ~CApp(void);
  38.         BOOL Init(void);
  39.     };
  40. typedef CApp *PCApp;
  41. void ObjectDestroyed(void);
  42. class CSquareClassFactory : public IClassFactory
  43.     {
  44.     protected:
  45.         ULONG           m_cRef;
  46.         HWND            m_hWnd;         //Main window (hidden)
  47.         HINSTANCE       m_hInst;        //Module instance
  48.     public:
  49.         CSquareClassFactory(HWND, HINSTANCE);
  50.         ~CSquareClassFactory(void);
  51.         //IUnknown members
  52.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  53.         STDMETHODIMP_(ULONG) AddRef(void);
  54.         STDMETHODIMP_(ULONG) Release(void);
  55.         //IClassFactory members
  56.         STDMETHODIMP  CreateInstance(LPUNKNOWN, REFIID, PPVOID);
  57.         STDMETHODIMP  LockServer(BOOL);
  58.     };
  59. typedef CSquareClassFactory *PCSquareClassFactory;
  60. //Information for the window in which we draw
  61. LRESULT APIENTRY SquareWndProc(HWND, UINT, WPARAM, LPARAM);
  62. #define SZCLASSSQUARE       TEXT("SquareWindow")
  63. class CSquare : public ISphereSquare
  64.     {
  65.     friend LRESULT APIENTRY SquareWndProc(HWND, UINT, WPARAM
  66.         , LPARAM);
  67.     protected:
  68.         ULONG           m_cRef;         //Object reference count
  69.         HWND            m_hWnd;         //Drawing window.
  70.         ITypeInfo      *m_pITypeInfo;   //Loaded
  71.         IUnknown       *m_pIUnkDisp;    //From CreateStdDispatch
  72.         //Plotting variables
  73.         double          m_cRadius;      //Edge length
  74.         double          m_dTheta;       //Angle
  75.         double          m_dDeclin;      //Declination
  76.         int             m_xOrg, m_yOrg; //Origin point
  77.         int             m_cx, m_cy;     //Window size
  78.         int             m_xPos, m_yPos; //Window position
  79.         COLORREF        m_crLinePos;    //Positive line color
  80.         HPEN            m_hPenPos;      //Positive line pen
  81.         COLORREF        m_crLineNeg;    //Negative line color
  82.         HPEN            m_hPenNeg;      //Negative line pen
  83.         COLORREF        m_crBack;       //Background color
  84.     public:
  85.         CSquare(void);
  86.         ~CSquare(void);
  87.         BOOL        Init(HWND, HINSTANCE);
  88.         void        CreatePens(BOOL, BOOL);
  89.         void        Draw(HDC);
  90.         //IUnknown Members
  91.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  92.         STDMETHODIMP_(ULONG) AddRef(void);
  93.         STDMETHODIMP_(ULONG) Release(void);
  94.         //ISphereSquare members
  95.         STDMETHODIMP_(double) get_Radius(void);
  96.         STDMETHODIMP_(void) put_Radius(double);
  97.         STDMETHODIMP_(double) get_Theta(void);
  98.         STDMETHODIMP_(void) put_Theta(double);
  99.         STDMETHODIMP_(double) get_Declination(void);
  100.         STDMETHODIMP_(void) put_Declination(double);
  101.         STDMETHODIMP_(long) get_BackColor(void);
  102.         STDMETHODIMP_(void) put_BackColor(long);
  103.         STDMETHODIMP_(long) get_LineColorPositive(void);
  104.         STDMETHODIMP_(void) put_LineColorPositive(long);
  105.         STDMETHODIMP_(long) get_LineColorNegative(void);
  106.         STDMETHODIMP_(void) put_LineColorNegative(long);
  107.         STDMETHODIMP_(void) Draw(void);
  108.         STDMETHODIMP_(void) SetCenterPoint(int, int);
  109.         STDMETHODIMP_(void) ShowWindow(int);
  110.         STDMETHODIMP_(void) SetWindowPosition(int, int);
  111.         STDMETHODIMP_(void) SetWindowSize(int, int);
  112.     };
  113. typedef CSquare *PCSquare;
  114. #define CBSQUAREWNDEXTRA        sizeof(PCSquare)
  115. #define SQWL_STRUCTURE          0
  116. //Handy constant
  117. #define PI 3.1415926535
  118. #endif //_SQUARE_H_