怎么让scrollview的滚动条自动滚动到底下

vb748 2011-03-10 08:51:38
如题

现在滚动条是出来了,我想让它自动滚动到底下,该咋办捏?bow~~
...全文
1067 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
vb748 2011-03-12
  • 打赏
  • 举报
回复
请路过的大侠不吝赐教啊。本人万分感谢!!!
bow~~
vb748 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 xianglitian 的回复:]

参考以下代码
C/C++ code

CRect rect;
int nMin, nMax;
GetClientRect(rect);
GetScrollRange(SB_HORZ, &nMin, &nMax);
SetScrollPos(SB_HORZ, (nMax-rect.Width())/2);
[/Quote]

O(∩_∩)O谢谢
向立天 2011-03-12
  • 打赏
  • 举报
回复
参考以下代码

CRect rect;
int nMin, nMax;
GetClientRect(rect);
GetScrollRange(SB_HORZ, &nMin, &nMax);
SetScrollPos(SB_HORZ, (nMax-rect.Width())/2);
vb748 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 fangongdalu7148 的回复:]

引用 10 楼 vb748 的回复:
引用 9 楼 fangongdalu7148 的回复:

int x,y;
x=0;
y=0;
GetScrollRange(SB_HORZ,&x,&y);
SetScrollPos(SB_HORZ,(x)/2,TRUE);
楼主你滚动条是水平的啊,,加上 垂直的坐标干嘛,不是找BUG吗

……
[/Quote]

囧,换个变量名问题还在的呀~~~~(>_<)~~~~
zgsdzhaolanxiang1 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 vb748 的回复:]
引用 9 楼 fangongdalu7148 的回复:

int x,y;
x=0;
y=0;
GetScrollRange(SB_HORZ,&amp;x,&amp;y);
SetScrollPos(SB_HORZ,(x)/2,TRUE);
楼主你滚动条是水平的啊,,加上 垂直的坐标干嘛,不是找BUG吗


哦,这个x应该是min y应该是max。都是水平滚动条……
[/Quote]
啊 我被误导了 呵呵 换成 MAX 应该没问题了吧
vb748 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 fangongdalu7148 的回复:]

int x,y;
x=0;
y=0;
GetScrollRange(SB_HORZ,&x,&y);
SetScrollPos(SB_HORZ,(x)/2,TRUE);
楼主你滚动条是水平的啊,,加上 垂直的坐标干嘛,不是找BUG吗
[/Quote]

哦,这个x应该是min y应该是max。都是水平滚动条的参数。肯能用了xy容易误导大家....
void GetScrollRange(
int nBar,
LPINT lpMinPos,
LPINT lpMaxPos )
const;
Parameters
nBar
Specifies the scroll bar to examine. The parameter can take one of the following values:
SB_HORZ Retrieves the position of the horizontal scroll bar.
SB_VERT Retrieves the position of the vertical scroll bar.
lpMinPos
Points to the integer variable that is to receive the minimum position.
lpMaxPos
Points to the integer variable that is to receive the maximum position.
zgsdzhaolanxiang1 2011-03-12
  • 打赏
  • 举报
回复
int x,y;
x=0;
y=0;
GetScrollRange(SB_HORZ,&x,&y);
SetScrollPos(SB_HORZ,(x)/2,TRUE);
楼主你滚动条是水平的啊,,加上 垂直的坐标干嘛,不是找BUG吗
vb748 2011-03-12
  • 打赏
  • 举报
回复
// move horizon scroll bar to center
int x,y;
x=0;
y=0;
GetScrollRange(SB_HORZ,&x,&y);
SetScrollPos(SB_HORZ,(x+y)/2,TRUE);

我试了下上面的,发现常常无法获取正确的x,y...
PostMessage(WM_VSCROLL, SB_BOTTOM, 0);这里貌似没有SB_CENTER 或者SB_MIDDLE
zgsdzhaolanxiang1 2011-03-12
  • 打赏
  • 举报
回复
int SetScrollPos( HWND hWnd,
int nBar,
int nPos,
BOOL bRedraw
);
向立天 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 vb748 的回复:]

引用 4 楼 xianglitian 的回复:

试试PostMessage(WM_VSCROLL, SB_BOTTOM, 0);

吼吼,真管用!
多谢啦
怎么让水平滚动条自动滚动到窗口中间呢@@
试了下貌似挺难弄....
[/Quote]
具体没做过
原理应该类似吧
看看改一下参数能不能实现
vb748 2011-03-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xianglitian 的回复:]

试试PostMessage(WM_VSCROLL, SB_BOTTOM, 0);
[/Quote]
吼吼,真管用!
多谢啦
怎么让水平滚动条自动滚动到窗口中间呢@@
试了下貌似挺难弄....
向立天 2011-03-12
  • 打赏
  • 举报
回复
试试PostMessage(WM_VSCROLL, SB_BOTTOM, 0);

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧