The control

Previous chapterNext chapter Show allShow all    Hide allHide all

Implementing the control is done with the class CD_SliderCtrlCtrl. This class has a standard Windows CSliderCtrl as a member, with which the control is subclassed. There are zenon interfaces in the interfaces IVariable and IElement, that had to be integrated. These are deduced from COleDispatchDriver.

class CCD_SliderCtrlCtrl : public COleControl

{

DECLARE_DYNCREATE(CCD_SliderCtrlCtrl)

private: //*** member variables

 

BOOL m_bInitialized;

BOOL m_bShowVertical;

BOOL m_bTicksBoth;

long m_nRangeStart;

long m_nRangeEnd;

long m_nTickOrientation;

IVariable m_interfaceVariable;

IElement m_interfaceElement;

CSliderCtrl m_wndSliderCtrl;

 

public:

CCD_SliderCtrlCtrl();

 

//{{AFX_VIRTUAL(CCD_SliderCtrlCtrl)

public:

virtual void OnDraw (CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);

virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

virtual void DoPropExchange (CPropExchange* pPX);

virtual void OnResetState ();

//}}AFX_VIRTUAL

 

protected:

~CCD_SliderCtrlCtrl();

//*** methods for the conversion from variant

double VariantToDouble(const VARIANT FAR *vValue);

 

DECLARE_OLECREATE_EX(CCD_SliderCtrlCtrl) // Class factory and guid

DECLARE_OLETYPELIB (CCD_SliderCtrlCtrl) // GetTypeInfo

DECLARE_PROPPAGEIDS (CCD_SliderCtrlCtrl) // Property page IDs

DECLARE_OLECTLTYPE (CCD_SliderCtrlCtrl) // Type name and misc status

 

//*** methods for the functionality of the SliderCtrl

BOOL IsSubclassedControl ();

LRESULT OnOcmCommand (WPARAM wParam, LPARAM lParam);

 

//{{AFX_MSG(CCD_SliderCtrlCtrl)

afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

afx_msg void HScroll(UINT nSBCode, UINT nPos);

afx_msg void HScroll(UINT nSBCode, UINT nPos);

afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

afx_msg void OnLButtonUp(UINT nFlags, CPoint point);

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

 

//{{AFX_DISPATCH(CCD_SliderCtrlCtrl)

afx_msg BOOL GetTickOnBothSides();

afx_msg void SetTickOnBothSides (short nNewValue);

afx_msg BOOL GetShowVertical();

afx_msg void SetShowVertical(BOOL bNewValue);

afx_msg short GetTickOrientation();

afx_msg void SetTickOrientation (short nNewValue);

afx_msg BOOL zenOnInit(LPDISPATCH pElementInterface);

afx_msg BOOL zenOnExit();

afx_msg short VariableTypes();

afx_msg short CanUseVariables();

afx_msg short MaxVariables();

//}}AFX_DISPATCH

DECLARE_DISPATCH_MAP()

 

afx_msg void AboutBox();

 

//{{AFX_EVENT(CCD_SliderCtrlCtrl)

//}}AFX_EVENT

DECLARE_EVENT_MAP()

 

public:

enum {

//{{AFX_DISP_ID(CCD_SliderCtrlCtrl)

dispidShowVertical = 1L,

dispidTicksOnBothSides = 2L,

dispidTickOrientation = 3L,

dispidZenOnInit = 4L,

dispidZenOnExit = 5L,

dispidVariableTypes = 6L,

dispidCanUseVariables = 7L,

dispidMaxVariables = 8L,

//}}AFX_DISP_ID

};

};