设置编辑控件中的滚动位置
我正在尝试在编辑控件中设置滚动位置,并且希望将其设置为从顶部到底部的 20%。我怎样才能通过百分比来做到这一点?
I'm trying to set the scroll position in edit control and I want set it 20% to bottom from the top. how I may go do that by taking a percentage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当窗口的标准垂直滚动条中发生滚动事件时,
WM_VSCROLL
消息将发送到窗口。当垂直滚动条控件中发生滚动事件时,该消息也会发送给该控件的所有者。http://msdn.microsoft.com/en -us/library/bb787577%28v=vs.85%29.aspx
您可以先
GetScrollRange()
(http://msdn.microsoft.com/en-us/library/ bb787587%28v=vs.85%29.aspx),计算有多少行,然后计算百分比。之后WindowProc()
与VM_SCROLL
或者更简单的解决方案使用SetScrollPos()
函数 http://msdn.microsoft.com/en-us/library/bb787597%28v= vs.85%29.aspx您可以在此处找到所有滚动功能http://msdn.microsoft.com/en-us/library/ff486021%28v=VS.85%29.aspx
希望这会有所帮助。
The
WM_VSCROLL
message is sent to a window when a scroll event occurs in the window's standard vertical scroll bar. This message is also sent to the owner of a vertical scroll bar control when a scroll event occurs in the control.http://msdn.microsoft.com/en-us/library/bb787577%28v=vs.85%29.aspx
You can first
GetScrollRange()
(http://msdn.microsoft.com/en-us/library/bb787587%28v=vs.85%29.aspx), calculate how many lines there are, then calculate the percentage. AfterwardWindowProc()
withVM_SCROLL
or, of a much more simpler solution use theSetScrollPos()
function http://msdn.microsoft.com/en-us/library/bb787597%28v=vs.85%29.aspxYou can find all the scroll functions here http://msdn.microsoft.com/en-us/library/ff486021%28v=VS.85%29.aspx
Hope this helped.
特别是对于编辑控件设置,滚动位置似乎并未实际将文本移动到预期位置。滚动条位置发生移动,但文本保持在原来的位置。
要滚动编辑框,我发现以下内容可以按我的预期工作:
Specifically for an edit control setting the scroll position doesn't appear to actually move the text to the position expected. The scroll bar position is moved but the text stays where it is at.
To scroll an edit box I found the following to work as I expected: