zenOnInit |
Develop ActiveX elements -> Example: CD_SliderCtrl -> The methods -> zenOnInit |
Show all Hide all |
The parameter dispElement contains the interface for the dynamic element. With this element the linked zenon variable determined. If it is valid, the range of the slider is set. Additionally the settings for the display (number of ticks, ) are set. If no variable is linked, the display range is set to 0 to 0. So the SliderCtrl cannot be operated. The variable m_bInitialized defines that values can be set from now on.
BOOL CCD_SliderCtrlCtrl::zenOnInit(LPDISPATCH dispElement)
{
//*** Determine the variable using the zenon element
m_interfaceElement = IElement(pElementInterface);
if (m_interfaceElement.GetCountVariable() > 0) {
short nIndex = 0;
m_interfaceVariable = IVariable
(m_interfaceElement.ItemVariable(COleVariant(nIndex)));
}
//*** Initialize the area of the Slider-Ctrl
if (m_interfaceVariable) {
//*** Define range
m_nRangeStart = (long) VariantToDouble(&m_interfaceVariable.GetRangeMin());
m_nRangeEnd = (long) VariantToDouble(&m_interfaceVariable.GetRangeMax());
m_wndSliderCtrl.SetRange(m_nRangeStart,m_nRangeEnd,TRUE);
//*** Define sub ticks
m_wndSliderCtrl.SetTicFreq(m_nTickCount);
m_wndSliderCtrl.SetPageSize(m_nTickCount);
m_wndSliderCtrl.SetLineSize(m_nLineSize);
} else {
m_wndSliderCtrl.SetRange(0,0,TRUE);
return FALSE;
}
m_bInitialized = TRUE;
return TRUE;
}