You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
821 B
C++

// MySlider.cpp : 实现文件
//
#include "stdafx.h"
#include "ExtendSliderCtrl.h"
// CMySlider
IMPLEMENT_DYNAMIC(CExtendSliderCtrl, CSliderCtrl)
CExtendSliderCtrl::CExtendSliderCtrl()
{
}
CExtendSliderCtrl::~CExtendSliderCtrl()
{
}
BEGIN_MESSAGE_MAP(CExtendSliderCtrl, CSliderCtrl)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CMySlider 消息处理程序
void CExtendSliderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CSliderCtrl::OnLButtonDown(nFlags, point);
CRect rectClient, rectChannel;
GetClientRect(rectClient);
GetChannelRect(rectChannel);
int nMax = 0;
int nMin = 0;
GetRange(nMin, nMax);
int nPos = (nMax - nMin) * (point.x - rectClient.left - rectChannel.left) / (rectChannel.right - rectChannel.left);
// 移动到鼠标位置
SetPos(nPos);
}