The control

Previous chapterNext chapter Show allShow all    Hide allHide all

Implementing the control is done with the class CLatchedSwitchCtrl. As members this class has the CPictureHolder objects for the storage of the bitmaps. Additionally three dispatch drivers for the dynamic element and the variables are generated:

class CLatchedSwitchCtrl : public COleControl




// Constructor




// Overrides

// ClassWizard generated virtual function overrides



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

virtual void DoPropExchange (CPropExchange* pPX);

virtual void OnResetState ();

virtual DWORD GetControlFlags();



// Implementation




DECLARE_OLECREATE_EX(CLatchedSwitchCtrl) // Class factory and guid

DECLARE_OLETYPELIB(CLatchedSwitchCtrl) // GetTypeInfo

DECLARE_PROPPAGEIDS(CLatchedSwitchCtrl) // Property page IDs

DECLARE_OLECTLTYPE(CLatchedSwitchCtrl) // Type name and misc status


// Message maps


afx_msg void OnLButtonDown(UINT nFlags, CPoint point);




// Dispatch maps


BOOL m_sollwertDirekt;

afx_msg void OnSollwertDirektChanged();

afx_msg LPPICTUREDISP GetSwitchOn();

afx_msg void SetSwitchOn(LPPICTUREDISP newValue);

afx_msg LPPICTUREDISP GetSwitchOff();

afx_msg void SetSwitchOff(LPPICTUREDISP newValue);

afx_msg LPPICTUREDISP GetLatchedOn();

afx_msg void SetLatchedOn(LPPICTUREDISP newValue);

afx_msg LPPICTUREDISP GetLatchedOff();

afx_msg void SetLatchedOff(LPPICTUREDISP newValue);

afx_msg short CanUseVariables();

afx_msg short VariableTypes();

afx_msg short MaxVariables();

afx_msg BOOL zenOnInit(LPDISPATCH dispElement);

afx_msg BOOL zenOnExit();


CPictureHolder m_SwitchOn;

CPictureHolder m_SwitchOff;

CPictureHolder m_LatchedOn;

CPictureHolder m_LatchedOff;




afx_msg void AboutBox();


// Event maps





 double VariantToDouble(const VARIANT FAR *v);

 void VariantToCString(CString *c,const VARIANT FAR *v);

 BOOL IsVariantString(const VARIANT FAR *v);

 BOOL IsVariantValue(const VARIANT FAR *v);


// Dispatch and event IDs


CString szVariable[2];

IElement m_dElement;

IVariable m_dLatchVar, m_dSwitchVar;


enum {


dispidSollwertDirekt = 1L,

dispidSwitchOn = 2L,

dispidSwitchOff = 3L,

dispidLatchedOn = 4L,

dispidLatchedOff = 5L,

dispidCanUseVariables = 6L,

dispidVariableTypes = 7L,

dispidMaxVariables = 8L,

dispidZenOnInit = 9L,

dispidZenOnExit = 10L,