关于GetScrollInfo 和 SetScrollInfo的一个问题

candy110 2008-03-13 10:33:18


SCROLLINFO si;
...
...
si.cbSize = sizeof (si) ;
si.fMask = SIF_DISABLENOSCROLL |SIF_ALL ;
GetScrollInfo (hwndNP, SB_VERT, &si) ;//得到si.nPos=4

si.nPos += vp.iEndRow-vp.iStartRow ;//得到si.nPos=10
si.fMask = SIF_DISABLENOSCROLL |SIF_POS ;
SetScrollInfo (hwndNP, SB_VERT, &si, TRUE) ;//si.nPos=4
GetScrollInfo (hwndNP, SB_VERT, &si) ;//这里si.nPos又等于4了

调用GetScrollInfo (hwndNP, SB_VERT, &si)之后si.nPos的值怎么又回去了?
...全文
721 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
candy110 2008-03-13
  • 打赏
  • 举报
回复
自己顶一个!
candy110 2008-03-13
  • 打赏
  • 举报
回复
[谢谢各位的关注
问题解决了.是自己疏忽造成的.


si.nPos += vp.iEndRow-vp.iStartRow ;
//在这之前没有给si.nPage和si.nMax重新复制.
//导致si.nMax-si.nPage+1 < si.nPos ;
//Set不成功,不过没有报错:)

星羽 2008-03-13
  • 打赏
  • 举报
回复
SetScrollInfo 的返回值是true吗
hastings 2008-03-13
  • 打赏
  • 举报
回复
以下摘录<windows程序设计>上的一个例子:
case WM_VSCROLL:
// Get all the vertical scroll bar information

si.cbSize = sizeof (si) ;
si.fMask = SIF_ALL ;
GetScrollInfo (hwnd, SB_VERT, &si) ;

// Save the position for comparison later on

iVertPos = si.nPos ;

switch (LOWORD (wParam))
{
case SB_TOP:
si.nPos = si.nMin ;
break ;

case SB_BOTTOM:
si.nPos = si.nMax ;
break ;

case SB_LINEUP:
si.nPos -= 1 ;
break ;

case SB_LINEDOWN:
si.nPos += 1 ;
break ;

case SB_PAGEUP:
si.nPos -= si.nPage ;
break ;

case SB_PAGEDOWN:
si.nPos += si.nPage ;
break ;

case SB_THUMBTRACK:
si.nPos = si.nTrackPos ;
break ;

default:
break ;
}
// Set the position and then retrieve it. Due to adjustments
// by Windows it may not be the same as the value set.

si.fMask = SIF_POS ;
SetScrollInfo (hwnd, SB_VERT, &si, TRUE) ;
GetScrollInfo (hwnd, SB_VERT, &si) ;

// If the position has changed, scroll the window and update it

if (si.nPos != iVertPos)
{
ScrollWindow (hwnd, 0, cyChar * (iVertPos - si.nPos),
NULL, NULL) ;
UpdateWindow (hwnd) ;
}
return 0 ;
candy110 2008-03-13
  • 打赏
  • 举报
回复
SetScrollInfo返回的就是4
但是si.nPos=10;
用GetLastError也没发现错误.

以前遇到过一次这样的问题.忘记当时这么搞定的了.
Supper_Jerry 2008-03-13
  • 打赏
  • 举报
回复
看一下返回值 看正确设置了吗

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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