Download source files - 67 Kb
This is an example of a simple ATL rotary control. The control is a copy of the rotary knob found on the Windows 2000 CD Player.
The control uses a minimum and maximum value, the position is calculation using the following calculated: once the limits are reached).
double a = -PI/4 + 3*PI/2 * (m_iMax - m_iPos)/(m_iMax - m_iMin);
The calculation sets the minimum stop at 8 o’clock and the maximum stop is a 4 o’clock. One enhancement that could be made to the project, is the facility for a Jogger button (A button that spins 360 Degrees) increasing a value until the minimum/maximum value is reached (the button still spins, but the value remains the same.
When the dial is moved a connection point event is fired:
DialChanged(int nPos)
This can be picked up in MFC, HTML page, or Visual Basic. The following methods are supported for retrieving and altering the limits and position are:
[propget, id(1), helpstring("property DialPosition")] HRESULT DialPosition([out, retval] short *pVal);
[propput, id(1), helpstring("property DialPosition")] HRESULT DialPosition([in] short newVal);
[id(2), helpstring("method SetMax")] HRESULT SetMax([in] short nMax);
[id(3), helpstring("method SetMin")] HRESULT SetMin([in] short nMin);
Any circular bitmap can be using for the background. When the left mouse button is press the LED positional indicator pulses.
The control has been tested with IE 5.0, Visual Basic 6.0 and MFC. One other thing to mention is that it would be rather simple to port this as MFC based CWnd
class, as this how it was developed in the first place.