Setting values

Previous chapterNext chapter Show allShow all    Hide allHide all

In the method LButtonDown the variable m_bInitialized is set to FALSE, and in the event LbuttonUp it is set to TRUE again. This makes sure, that the value can be changed. Otherwise the routine OnDraw would be executed and the old value would be displayed.

void CCD_SliderCtrlCtrl::OnLButtonDown(UINT nFlags, CPoint point)

{

m_bInitialized = FALSE;

COleControl::OnLButtonDown(nFlags, point);

}

void CCD_SliderCtrlCtrl::OnLButtonUp(UINT nFlags, CPoint point)

{

m_bInitialized = TRUE;

COleControl::OnLButtonUp(nFlags, point);

}

A value is sent to the hardware, when the slider is moved. In the methods Hscroll resp. Vscroll the value is sent to the hardware (depending if it is a horizontal or a vertical slider).

void CCD_SliderCtrlCtrl::HScroll(UINT nSBCode, UINT nPos)

{

switch (nSBCode) {

case TB_LINEUP:

case TB_PAGEUP:

case TB_LINEDOWN:

case TB_PAGEDOWN:

case TB_THUMBTRACK:

case TB_THUMBPOSITION:{

//*** Set value without dialog ?

int nValue = m_wndSliderCtrl.GetPos();

COleVariant cValue((short) nValue,VT_I2);

m_interfaceVariable.SetValue(cValue);

}

}

}