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



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;







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

virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

virtual void DoPropExchange (CPropExchange* pPX);

virtual void OnResetState ();





//*** 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 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 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_msg void AboutBox();







enum {


dispidShowVertical = 1L,

dispidTicksOnBothSides = 2L,

dispidTickOrientation = 3L,

dispidZenOnInit = 4L,

dispidZenOnExit = 5L,

dispidVariableTypes = 6L,

dispidCanUseVariables = 7L,

dispidMaxVariables = 8L,