滑动条:

1.  GetScrollBarCtrl 

The CWnd implementation of this function simply returns NULL. Derived classes, such as CView, implement the described functionality.

在cwnd中是null,在view中才会有值

但可以直接用滑动条的函数,比如

GetScrollPos

http://blog.163.com/lvan100@yeah/blog/static/6811721420101176353748/

可参见



2. 可以在nc_paint中重绘




















/


如果你试过用GetScrollBarCtrl()函数去获取对话框内自动的滚动条控件,那么你绝对是不能成功的。为什么呢?

MSDN 这样解释:

The CWnd implementation of this function simply returns NULL. (这个函数对于CWnd类只是简单的返回一个NULL值。)

Derived classes, such as CView, implement the described functionality.(除了一些如CView的类,才会实行函数声明的功能。)

呵呵!知道了吧。但是我们怎么操纵这样的滚动条呢?回答:直接操纵!即把对话框当做一个滚动条对象就ok了。

如下列代码:

BOOL C***Ctrl::OnInitDialog()
{
 CDialogEx::OnInitDialog();
 
 SCROLLINFO sbinfo;
 sbinfo.fMask = SIF_ALL;
 sbinfo.nMax = 100;
 sbinfo.nMin = 0;
 sbinfo.nPage = 90;
 sbinfo.nPos = 0;
 SetScrollInfo(SB_VERT,&sbinfo,TRUE);
 
 return TRUE;   
}
BOOL C***Ctrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
 // TODO: 在此添加消息处理程序代码和/或调用默认值
 int nflag = zDelta>0?1:-1;
 int nCurpos,nMin,nMax,nThumbWidth;
 SCROLLINFO siInfo;
 GetScrollInfo(SB_VERT,&siInfo);
 nCurpos = siInfo.nPos;
 nMin = siInfo.nMin;
 nMax = siInfo.nMax;
 nThumbWidth = siInfo.nPage;
 SetScrollPos(SB_VERT,nCurpos - nflag);
 int nScroll = nflag * 11;
 if (nCurpos+nThumbWidth < nMax && nCurpos !=0)
  ScrollWindow(0,nScroll); 
 
 return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
}

说实话,我也是写这篇文章的时候才真正读懂上面的两句引文。唉!



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值