The control |
Develop ActiveX elements -> Example: LatchedSwitch -> The control |
Show all Hide 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
{
DECLARE_DYNCREATE(CLatchedSwitchCtrl)
// Constructor
public:
CLatchedSwitchCtrl();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CLatchedSwitchCtrl)
public:
virtual void OnDraw (CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
virtual void DoPropExchange (CPropExchange* pPX);
virtual void OnResetState ();
virtual DWORD GetControlFlags();
//}}AFX_VIRTUAL
// Implementation
protected:
~CLatchedSwitchCtrl();
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(CLatchedSwitchCtrl)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
// Dispatch maps
//{{AFX_DISPATCH(CLatchedSwitchCtrl)
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();
//}}AFX_DISPATCH
CPictureHolder m_SwitchOn;
CPictureHolder m_SwitchOff;
CPictureHolder m_LatchedOn;
CPictureHolder m_LatchedOff;
DECLARE_DISPATCH_MAP()
afx_msg void AboutBox();
// Event maps
//{{AFX_EVENT(CLatchedSwitchCtrl)
//}}AFX_EVENT
DECLARE_EVENT_MAP()
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
public:
CString szVariable[2];
IElement m_dElement;
IVariable m_dLatchVar, m_dSwitchVar;
enum {
//{{AFX_DISP_ID(CLatchedSwitchCtrl)
dispidSollwertDirekt = 1L,
dispidSwitchOn = 2L,
dispidSwitchOff = 3L,
dispidLatchedOn = 4L,
dispidLatchedOff = 5L,
dispidCanUseVariables = 6L,
dispidVariableTypes = 7L,
dispidMaxVariables = 8L,
dispidZenOnInit = 9L,
dispidZenOnExit = 10L,
//}}AFX_DISP_ID
};
};