How can I add a horizontal scrollbar to a VBA ListBox

后端 未结 6 1058
星月不相逢
星月不相逢 2021-01-14 00:49

I\'d like to add a horizontal scrollbar to a VBA ListBox.

It appears that the built in ListBox does not add a horizontal scrollbar automatically. I have a number of

6条回答
  •  爱一瞬间的悲伤
    2021-01-14 01:28

    In that article, the only reason it's getting ScaleMode is to set the width of the horizontal scroll bar. You don't have to do that.

    SendMessageByNum List1.hwnd, LB_SETHORIZONTALEXTENT, 800, 0
    

    where 800 is the pixel width you want the list box to be able to scroll right to.

    You will still need the hWnd. Best bet there is to use an external DLL (written in VB) which can enum through child windows of your process until it finds the windows class for the listbox (you will need to find some way to uniquely identify its parent, such as the window title/text or something). That same DLL could also do the SendMessage call above to set the horizontal text extent (perhaps also it could measure the width of the contained list items).

提交回复
热议问题