我正在使用组合框控件来显示存储在数据库中的名称(我需要保留空间,这就是我使用它而不是 ListView 的原因,例如)。
我的问题是有时文本比组合框长,所以看不到其中的一部分。
有没有办法调整组合框列表框的大小,以便它可以完全显示文本,或者至少启用某种水平滚动,以便用户可以滚动查看整个文本?
查看组合框文档,我没有找到任何可以解决我的问题的样式。尝试在我的 CreateWindowEx
调用中添加 WS_HSCROLL
作为样式也无济于事。
谢谢。
最佳答案
您正在寻找 CB_SETHORIZONTALEXTENT
消息。
An application sends the CB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden or, if the combo box has the CBS_DISABLENOSCROLL style, disabled.
Parameters
wParam
Specifies the scrollable width of the list box, in pixelslParam
This parameter is not used.
关于c++ - 动态调整组合框的宽度,以便显示整个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27374086/