SoftechSoftware homepage
SoftechSoftware Email
Abstract
You need GDI+ installed to use this control.
CKnobControlST
is a class derived from MFC CSliderCtrl
class. The control has been created as an exercise of converting an existing control written in C# into a new one with the same features written in C++. The conversion was quite simple. You can find the original control here. CKnobControlST
code is more robust than the original one.
How to integrate CKnobControlST in your application
In your project include the following files:
- KnobControlST.h
- KnobControlST.cpp
With dialog editor create a slider control called, for example,
IDC_KNOB
.
Then create a member variable for this control:
CKnobControlST m_knbControl;
Now attach the knob control to CKnobControlST
. For dialog-based applications, in your OnInitDialog:
CDialog::OnInitDialog();
m_knbControl.SubclassDlgItem(IDC_KNOB, this);
Or in your DoDataExchange
:
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_KNOB, m_knbControl);
The control will have the same default range and start position as in the base MFC class CSliderCtrl
. These values can be modified using the same methods of the base class such as, for example, SetRange
or SetPos
. Following is the list of base class methods currently supported:
GetRangeMax
GetRangeMin
GetRange
SetRangeMax
SetRangeMin
SetRange
GetPos
SetPos
At this moment other specific
CSliderCtrl
features are not supported.
Your slider control is now a
CKnobControlST
!
Class methods
SetIcon
Sets the icon to be displayed. Any previous icon will be removed.
DWORD SetIcon(int nIcon, BOOL bRepaint = TRUE, HINSTANCE hInstance = NULL)
SetIcon
Sets the icon to be displayed. Any previous icon will be removed.
DWORD SetIcon(HICON hIcon, BOOL bRepaint = TRUE)
SetColors
Sets the foreground and background colors of the control.
void SetColors(Color cFgColor, Color cBkColor, BOOL bRepaint = TRUE)
SetFgColor
Sets the foreground color of the control.
void SetFgColor(Color cFgColor, BOOL bRepaint = TRUE)
SetBkColor
Sets the background color of the control.
void SetBkColor(Color cBkColor, BOOL bRepaint = TRUE)
SetScaleColor
Sets the scale color of the control.
void SetScaleColor(Color cColor, BOOL bRepaint = TRUE)
SetAlpha
Sets the alpha component of the colors used to draw the control.
void SetAlpha(BYTE byAlpha, BOOL bRepaint = TRUE)
GetAlpha
Returns the alpha component of the colors used to draw the control.
BYTE GetAlpha()
ShowLargeScale
Sets if the large scale around the control must be drawn.
void ShowLargeScale(BOOL bShow, BOOL bRepaint = TRUE)
ShowSmallScale
Sets if the small scale around the control must be drawn.
void ShowSmallScale(BOOL bShow, BOOL bRepaint = TRUE)
SetLargeChangeValue
Sets the value of the large control step.
void SetLargeChangeValue(int nLargeChange, BOOL bRepaint = TRUE)
SetSmallChangeValue
Sets the value of the small control step.
void SetSmallChangeValue(int nSmallChange, BOOL bRepaint = TRUE)
SetTooltipText
Sets the text to show in the control tooltip.
void SetTooltipText(int nId, BOOL bActivate = TRUE)
SetTooltipText
Sets the text to show in the control tooltip.
void SetTooltipText(LPCTSTR lpszText, BOOL bActivate = TRUE)
ActivateTooltip
Enables or disables the control tooltip.
void ActivateTooltip(BOOL bActivate = TRUE)
SetChangeCallback
Sets the callback message that will be sent to the specified window each time the control reaches a new position.
DWORD SetChangeCallback(HWND hWnd, UINT nMessage, WPARAM wParam = 0,
LPARAM lParam = 0)
DrawTransparent
Enables the transparent mode. Note: this operation is not reversible.
DrawTransparent
should be called just after the control is created. Do not use trasparent controls until you really need it (you have a bitmapped background) since each transparent control makes a copy in memory of its background. This may bring unnecessary memory use and execution overload.
DWORD DrawTransparent(BOOL bRepaint = FALSE)
OnDrawBackground
This function is called every time the control background needs to be painted.
If the control is in transparent mode this function will NOT be called. This is a virtual function that can be rewritten in
CKnobControlST
-derived classes.
virtual DWORD OnDrawBackground(Graphics* pGfx, LPCRECT pRect)
OnDrawIcon
This function is called every time the icon associated to the control needs to be painted.
If the control has no icon this function will NOT be called. This is a virtual function that can be rewritten in
CKnobControlST
-derived classes.
virtual DWORD OnDrawIcon(Graphics* pGfx, Rect* rpKnob)
GetVersionI
Returns the class version as a short value.
static short GetVersionI()
GetVersionC
Returns the class version as a string value.
static LPCTSTR GetVersionC()
History
- v1.0 (15/June/2003)
First release
Disclaimer
THE SOFTWARE AND THE ACCOMPANYING FILES ARE DISTRIBUTED "AS IS" AND WITHOUT ANY WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO REPONSIBILITIES FOR POSSIBLE DAMAGES OR EVEN FUNCTIONALITY CAN BE TAKEN. THE USER MUST ASSUME THE ENTIRE RISK OF USING THIS SOFTWARE.