xiexie
定义一个CToolTipCtrl* m_ToolTilCtrl;的成员变量。
再初始化函数中添加
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ToolTipCtrl = new CToolTipCtrl;
m_ToolTipCtrl->Create(this);
m_Slider.SetToolTips(m_ToolTipCtrl);
CWnd* pWnd = (CWnd*)GetDlgItem(IDC_SLIDER1);
m_ToolTipCtrl->AddTool(pWnd,"SlideCtrl");
m_ToolTipCtrl->SetTipBkColor(RGB(100,100,100));//设置tooltip的背景色
m_ToolTipCtrl->SetTipTextColor(RGB(0,255,255));//设置tip文本的颜色
m_ToolTipCtrl->Activate(TRUE);
}
然后再重载虚函数PreTranslateMessage:
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
if (NULL != m_ToolTipCtrl)
m_ToolTipCtrl->RelayEvent(pMsg);
return CDialog::PreTranslateMessage(pMsg);
}
CSliderCtrlEx - A slider with background colors to indicate ranges
By Harold Bamford
http://www.codeproject.com/useritems/csliderctrlex.asp?target=slider
Skin based slider control
By Ashok Jaiswal
http://www.codeproject.com/miscctrl/skinnedslidercontrol.asp?target=slider