1.Slider
CSliderCtrl m_wndSlider;
// m_wndSlider.Create(this); //when and where is it used?
m_wndSlider.SetRange(0,8);
m_wndSlider.SetPos(4);
m_wndSlider.SetTic(2);
m_wndSlider.SetTic(4);
m_wndSlider.SetTic(6);
m_wndSlider.SetSelection (3, 7);
CSliderCtrl provides more than two dozen functions you can use to operate on slider controls. Other useful member functions include SetPageSize, which sets the number of units the thumb moves when the channel is clicked with the mouse or when Page Up or Page Down is pressed; GetTic, GetTicPos, GetTicArray, and GetNumTicks, which return information about tick marks; and ClearSel, which removes a selection range. See the MFC documentation for more information regarding these and other CSliderCtrl function members.
2.Spin Button
EDITTEXT IDC_EDIT, 60, 80, 40, 14, ES_AUTOHSCROLL
CONTROL "", IDC_SPIN, "msctls_updown32", UDS_SETBUDDYINT ¦ UDS_AUTOBUDDY ¦ UDS_ALIGNRIGHT, 0, 0, 0, 0
// m_wndSpinBtn.Create when and where is it used?
CSpinButtonCtrl m_wndSpinBtn;
m_wndSpinBtn.SetBase(16); // display hexadecimal numbers
UDACCEL uda[4];
uda[0].nSec = 0;
uda[0].nInc = 1;
uda[1].nSec = 2;
uda[1].nInc = 2;
uda[2].nSec = 4;
uda[2].nInc = 10;
uda[3].nSec = 8;
uda[3].nInc = 100;
pSpinButton->SetAccel (4, uda);
You set a spin button control's range and position with CSpinButtonCtrl::SetRange and CSpinButtonCtrl::SetPos.
UDACCEL* puda = new UDACCEL[nCount];
pSpinButton->GetAccel (nCount, puda);
// Do something with the array.
delete[] puda;
3.ToolTip
CToolTipCtrl m_ctlTt;
m_ctlTT.Create (this);
m_ctlTT.AddTool (pWnd, _T ("This is a window"), NULL, 0);
m_ctlTT.AddTool (pWnd, _T ("This is a rectangle"),CRect (32, 32, 64, 64), IDT_RECTANGLE);
class CMyToolTipCtrl : public CToolTipCtrl
{
public:
BOOL AddWindowTool (CWnd* pWnd, LPCTSTR pszText);
BOOL AddRectTool (CWnd* pWnd, LPCTSTR pszText, LPCRECT pRect, UINT nIDTool);
};
BOOL CMyToolTipCtrl::AddWindowTool (CWnd* pWnd, LPCTSTR pszText)
{
TOOLINFO ti;
ti.cbSize = sizeof (TOOLINFO);
ti.uFlags = TTF_IDISHWND ¦ TTF_SUBCLASS;
ti.hwnd = pWnd->GetParent ()->GetSafeHwnd ();
ti.uId = (UINT) pWnd->GetSafeHwnd ();
ti.hinst = AfxGetInstanceHandle ();
ti.lpszText = (LPTSTR) pszText;
return (BOOL) SendMessage (TTM_ADDTOOL, 0, (LPARAM) &ti);
}
BOOL CMyToolTipCtrl::AddRectTool (CWnd* pWnd, LPCTSTR pszText,
LPCRECT lpRect, UINT nIDTool)
{
TOOLINFO ti;
ti.cbSize = sizeof (TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = pWnd->GetSafeHwnd ();
ti.uId = nIDTool;
ti.hinst = AfxGetInstanceHandle ();
ti.lpszText = (LPTSTR) pszText;
::CopyRect (&ti.rect, lpRect);
return (BOOL) SendMessage (TTM_ADDTOOL, 0, (LPARAM) &ti);
}
m_ctlTT.AddWindowTool (GetDlgItem (IDC_SLIDER), MAKEINTRESOURCE (IDS_SLIDER));
m_ctlTT.AddWindowTool (GetDlgItem (IDC_EDITHORZ),MAKEINTRESOURCE (IDS_EDITHORZ));
m_ctlTT.AddWindowTool (GetDlgItem (IDC_EDITVERT),MAKEINTRESOURCE (IDS_EDITVERT));