Back to index

plt-scheme  4.2.1
testcontrol.h
Go to the documentation of this file.
00001 // TestControl.h : Declaration of the CTestControl
00002 
00003 #ifndef __TESTCONTROL_H_
00004 #define __TESTCONTROL_H_
00005 
00006 #include "resource.h"       // main symbols
00007 #include <windowsx.h>
00008 #include <atlctl.h>
00009 #include "testobjectCP.h"
00010 
00011 
00013 // CTestControl
00014 class ATL_NO_VTABLE CTestControl :
00015        public CComObjectRootEx<CComSingleThreadModel>,
00016        public CStockPropImpl<CTestControl, ITestControl, &IID_ITestControl, &LIBID_TESTOBJECTLib>,
00017        public CComControl<CTestControl>,
00018        public IPersistStreamInitImpl<CTestControl>,
00019        public IOleControlImpl<CTestControl>,
00020        public IOleObjectImpl<CTestControl>,
00021        public IOleInPlaceActiveObjectImpl<CTestControl>,
00022        public IViewObjectExImpl<CTestControl>,
00023        public IOleInPlaceObjectWindowlessImpl<CTestControl>,
00024        public IConnectionPointContainerImpl<CTestControl>,
00025        public IPersistStorageImpl<CTestControl>,
00026        public ISpecifyPropertyPagesImpl<CTestControl>,
00027        public IQuickActivateImpl<CTestControl>,
00028        public IDataObjectImpl<CTestControl>,
00029        public IProvideClassInfo2Impl<&CLSID_TestControl, &DIID__ITestControlEvents, &LIBID_TESTOBJECTLib>,
00030        public IPropertyNotifySinkCP<CTestControl>,
00031        public CComCoClass<CTestControl, &CLSID_TestControl>,
00032        public CProxy_ITestControlEvents< CTestControl >
00033 {
00034 private:
00035   long the_value;
00036 public:
00037        CTestControl()
00038        {
00039          the_value = 0L;
00040        }
00041 
00042 DECLARE_REGISTRY_RESOURCEID(IDR_TESTCONTROL)
00043 
00044 DECLARE_PROTECT_FINAL_CONSTRUCT()
00045 
00046 BEGIN_COM_MAP(CTestControl)
00047        COM_INTERFACE_ENTRY(ITestControl)
00048        COM_INTERFACE_ENTRY(IDispatch)
00049        COM_INTERFACE_ENTRY(IViewObjectEx)
00050        COM_INTERFACE_ENTRY(IViewObject2)
00051        COM_INTERFACE_ENTRY(IViewObject)
00052        COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
00053        COM_INTERFACE_ENTRY(IOleInPlaceObject)
00054        COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
00055        COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
00056        COM_INTERFACE_ENTRY(IOleControl)
00057        COM_INTERFACE_ENTRY(IOleObject)
00058        COM_INTERFACE_ENTRY(IPersistStreamInit)
00059        COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
00060        COM_INTERFACE_ENTRY(IConnectionPointContainer)
00061        COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
00062        COM_INTERFACE_ENTRY(IQuickActivate)
00063        COM_INTERFACE_ENTRY(IPersistStorage)
00064        COM_INTERFACE_ENTRY(IDataObject)
00065        COM_INTERFACE_ENTRY(IProvideClassInfo)
00066        COM_INTERFACE_ENTRY(IProvideClassInfo2)
00067        COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
00068 END_COM_MAP()
00069 
00070 BEGIN_PROP_MAP(CTestControl)
00071        PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
00072        PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
00073        PROP_ENTRY("Caption", DISPID_CAPTION, CLSID_NULL)
00074        // Example entries
00075        // PROP_ENTRY("Property Description", dispid, clsid)
00076        // PROP_PAGE(CLSID_StockColorPage)
00077 END_PROP_MAP()
00078 
00079 BEGIN_CONNECTION_POINT_MAP(CTestControl)
00080        CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
00081        CONNECTION_POINT_ENTRY(DIID__ITestControlEvents)
00082 END_CONNECTION_POINT_MAP()
00083 
00084 BEGIN_MSG_MAP(CTestControl)
00085        CHAIN_MSG_MAP(CComControl<CTestControl>)
00086        DEFAULT_REFLECTION_HANDLER()
00087        MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
00088        MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
00089        MESSAGE_HANDLER(WM_MBUTTONDOWN, OnMButtonDown)
00090        MESSAGE_HANDLER(WM_MBUTTONUP, OnMButtonUp)
00091        MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
00092        MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
00093        MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
00094 END_MSG_MAP()
00095 // Handler prototypes:
00096 //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
00097 //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
00098 //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
00099 
00100 
00101 
00102 // IViewObjectEx
00103        DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
00104 
00105 // ITestControl
00106 public:
00107        STDMETHOD(FloatTest)(double n1,double n2,/*[out,retval]*/double *n3);
00108        STDMETHOD(UnsignedTest)(unsigned n1,unsigned n2,/*[out,retval]*/unsigned *n3);
00109        STDMETHOD(ShortTest)(short int n1,short int n2,/*[out,retval]*/short int *n3);
00110        STDMETHOD(StringTest)(BSTR s1,BSTR s2,/*[out,retval]*/BSTR *s3);
00111        STDMETHOD(AddTest)(long n1,long *n2,/*[out,retval]*/long *n3);
00112        STDMETHOD(get_Numprop)(long ndx,long *retVal);
00113        STDMETHOD(put_Numprop)(long ndx,long newVal);
00114 
00115        HRESULT OnDraw (ATL_DRAWINFO& di)
00116        {
00117               RECT& rc = *(RECT*)di.prcBounds;
00118               Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom);
00119 
00120               SetTextAlign(di.hdcDraw, TA_CENTER|TA_BASELINE);
00121               LPCTSTR pszText = _T("MysterX Test Control");
00122               TextOut(di.hdcDraw,
00123                      (rc.left + rc.right) / 2,
00124                      (rc.top + rc.bottom) / 2,
00125                      pszText,
00126                      lstrlen(pszText));
00127 
00128               return S_OK;
00129        }
00130 
00131        CComBSTR m_bstrCaption;
00132 
00133        LRESULT OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00134        {
00135          Fire_MouseDown (0x1, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00136          Fire_Click();
00137          return DefWindowProc (uMsg, wParam, lParam);
00138        }
00139 
00140        LRESULT OnLButtonUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00141        {
00142          Fire_MouseUp (0x1, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00143          return DefWindowProc (uMsg, wParam, lParam);
00144        }
00145 
00146        LRESULT OnMButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00147        {
00148          Fire_MouseDown (0x4, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00149          Fire_Click();
00150          return DefWindowProc (uMsg, wParam, lParam);
00151        }
00152 
00153        LRESULT OnMButtonUp (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00154        {
00155          Fire_MouseUp (0x4, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00156          return DefWindowProc (uMsg, wParam, lParam);
00157        }
00158 
00159        LRESULT OnRButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00160        {
00161          Fire_MouseDown (0x2, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00162          Fire_Click();
00163          return DefWindowProc(uMsg, wParam, lParam);
00164        }
00165 
00166        LRESULT OnRButtonUp (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00167        {
00168          Fire_MouseUp (0x2, wParam, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00169          return DefWindowProc (uMsg, wParam, lParam);
00170        }
00171 
00172        LRESULT OnMouseMove (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
00173        {
00174          short button;
00175          short shift;
00176 
00177          button = wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON);
00178          shift = wParam & (MK_CONTROL | MK_SHIFT);
00179 
00180          Fire_MouseMove (button, shift, GET_X_LPARAM (lParam), GET_Y_LPARAM (lParam));
00181 
00182          return DefWindowProc (uMsg, wParam, lParam);
00183        }
00184 };
00185 
00186 #endif //__TESTCONTROL_H_