c++ - 动态调整组合框的宽度,以便显示整个字符串

标签 c++ c winapi combobox

我正在使用组合框控件来显示存储在数据库中的名称(我需要保留空间,这就是我使用它而不是 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 pixels

lParam
This parameter is not used.

关于c++ - 动态调整组合框的宽度,以便显示整个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27374086/

相关文章:

c++ - 如何在 X86 PC 上为 arm 编译 gcc 编译器

c++ - 如何在 boost::gil 中使用 alpha channel 调整 png 图像的大小

c++ - ARM 中是否有与 rdtsc 等效的指令?

c++ - 向事件窗口发送 GID_ZOOM 手势

c# - 在 Windows XP 登录屏幕 (.NET/Pinvoke) 上运行进程(使用 GUI)

c++ - 对汇编函数的 undefined reference

c - 如何以编程方式编辑路由表

python - 向/从 Python 和 C 传递 2D 可变长度数组的好方法?

c - 具有常量表达式的初始化程序在 C99 中可能溢出

winapi - 是否有 WinAPI 方法来检测 LogMeIn 等远程应用程序?