MFC CCheckListBox的垂直滚动条未更新 [英] MFC CCheckListBox's vertical scrollbar is not updated

查看:181
本文介绍了MFC CCheckListBox的垂直滚动条未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不用CCheckListBox替换旧的MFCSharpGrid控件.

I had to replace an old MFCSharpGrid control with a CCheckListBox.

现在,在显示列表框的垂直滚动条之后,似乎可以将正确的事件(向上/向下滚动和向上/向下翻页)发送到列表的工作区,并且允许滚轮滚动隐藏滚动条时不可用.

Now, after displaying the vertical scroll-bar for the list-box, it seems to send the correct events (the line up/down and page up/down) to the list's client area, and it allows mouse-wheel scrolling which isn't available with the scroll-bar hidden.

但是,滚动条本身不会更新:滚动客户区时,拇指不会移动(即使响应滚动条上的滚动也不会移动),并且拇指的大小与页面大小不成比例

However, the scroll-bar is not updated itself: the thumb is not moving when scrolling the client area (not even in response to scrolls from the scroll-bar), and the thumb's size is not proportional to the page-size.

创建列表框的方式大致如下:

The list-box is created more or less like this:

m_grid.Create(LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY, m_gridRect, this, IDC_GRID1);

反复添加字符串,然后我们要求显示滚动条,如下所示:

Strings are added iteratively, and then we request displaying the scroll-bar like this:

m_grid.ShowScrollBar(SB_VERT, TRUE);

尝试将SCROLLINFO设置为最小/最大/页面大小并不能解决位置更新问题.

Trying to set the SCROLLINFO for min/max/page-size didn't solve the position update problem.

我在这里想念什么?

推荐答案

您不想手动使用ShowScrollBar.删除它,而是使用WS_VSCROLL样式创建列表框.

You don't want to manually use ShowScrollBar. Delete that, and rather create the listbox with WS_VSCROLL style.

m_grid.Create(WS_VSCROLL | LBS_HASSTRINGS | LBS_OWNERDRAWFIXED | LBS_NOTIFY, m_gridRect, this, IDC_GRID1);

这样,当内容超过控件的长度时,您将自动获得垂直滚动条.

That way you get a vertical scrollbar automatically when the contents exceed the length of of the control.

这篇关于MFC CCheckListBox的垂直滚动条未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆