afx_msg void OnHScroll( UINT nSBCode, UINT nPos, CScrollBar* pScrollBar );中的三个参数的作用

nSBCode
Specifies a scroll-bar code that indicates the user's scrolling request. This parameter can be one of the following:
表名用户滚动需求的代码,参数是以下的几种之一:
SB_LEFT   Scroll to far left.滚动到左边

SB_ENDSCROLL   End scroll.滚动到末尾

SB_LINELEFT   Scroll left.向左滚动

SB_LINERIGHT   Scroll right.向右滚动

SB_PAGELEFT   Scroll one page left.向左滚动一页

SB_PAGERIGHT   Scroll one page right.向右滚动一页

SB_RIGHT   Scroll to far right.滚动到右边

SB_THUMBPOSITION   Scroll to absolute position. The current position is specified by the nPos parameter.到绝对位置,位置参数由nPos确定


SB_THUMBTRACK   Drag scroll box to specified position. The current position is specified by the nPos parameter.拖动滚动条到自定义位置,位置参数由nPos定义

nPos
Specifies the scroll-box position if the scroll-bar code is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, not used. Depending on the initial scroll range, nPos may be negative and should be cast to an int if necessary.
当nSBCode是SB_THUMBPOSITION 或SB_THUMBTRACK时该参数定义了滚动条的位置,否则处于未使用状态,这取决于你对该控件初始的设置.

pScrollBar
If the scroll message came from a scroll-bar control, contains a pointer to the control. If the user clicked a window's scroll bar, this parameter is NULL. The pointer may be temporary and should not be stored for later use.

如果滚动的消息来自滚动控件,它包含了指向这个控件的指针。如果用户单击一个窗口的滚动条,这个参数为空。这个指针可能是临时的,所以不要为了以后的使用而存储这个参数。(MSDN上的东西)

nSBCode:代表滚动方向。
nPos:如果nSBCode 为:SB_THUMBPOSITION or SB_THUMBTRACK其中之一,代表滚动条的位置。其他情况未用。
pScrollBar:滚动条窗口包装类指针。

以下为范例:

void CSliderUseDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
int iRed,iGreen,iBlue;
//得到红色、绿色和蓝色滑动条滚动事件
if((pScrollBar->GetDlgCtrlID()==IDC_SLIDER_RED)
||(pScrollBar->GetDlgCtrlID()==IDC_SLIDER_GREEN)
||(pScrollBar->GetDlgCtrlID()==IDC_SLIDER_BLUE))
{
CSliderCtrl *pSliderRed = (CSliderCtrl *)GetDlgItem(IDC_SLIDER_RED);
CSliderCtrl *pSliderGreen = (CSliderCtrl *)GetDlgItem(IDC_SLIDER_GREEN);
CSliderCtrl *pSliderBlue = (CSliderCtrl *)GetDlgItem(IDC_SLIDER_BLUE);


iRed = pSliderRed->GetPos();
iGreen = pSliderGreen->GetPos();
iBlue = pSliderBlue->GetPos();
}


UpdateData(TRUE);
CBrush colorBrush;
COLORREF clRGB;
//得到RGB颜色值
clRGB = RGB(iRed, iGreen, iBlue);
CClientDC *pClientDC;
//得到绘图环境
pClientDC = new CClientDC(this);
colorBrush.CreateSolidBrush(clRGB);
CRect rect(80, 120, 160, 200);
//显示颜色
pClientDC->FillRect(rect, &colorBrush);
delete pClientDC;


CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值