curly
Full Member
Posts: 161
|
Post by curly on Sept 28, 2021 11:59:26 GMT -5
Hi, regarding Listboxes and word-wrapping,
Is it possible please? I've tried a few stylebits I found in older posts, but nothing seems to exist for listboxes? Looks gloomy!
Kind regards, David
|
|
|
Post by tsh73 on Sept 28, 2021 13:18:57 GMT -5
How it supposed to work at all? Listbox has same-height lines. If line in the middle is too long, it should wrap - where?
|
|
|
Post by Rod on Sept 28, 2021 13:27:16 GMT -5
You can hide trailing text by inserting chr$(10), or is it chr$(13) In any event the listbox only shows the first part of the string the rest is hidden but preserved. Stefan showed this trick.
|
|
|
Post by Walt Decker on Sept 28, 2021 16:10:30 GMT -5
Change the list box style to WS.HSCROLL = HEXDEC("&H00100000") and send the message LB.SETHORIZONTALEXTENT = HEXDEC("&H0194") e. g. STYLEBITS #1111.LBX, WS.HSCROLL, 0, 0, 0 CALLDLL #user32, "SendMessageA", LbHndl AS ULONG, LB.SETHORIZONTALEXTENT AS ULONG, NumPixels AS LONG, 0 AS LONG, RetVal AS VOID
PS: You can change the height of individual row by using the LBS.OWNERDRAWVARIABLE style, but in LB that would be really tricky. I could work it out.
======================================================================== LB.SETHORIZONTALEXTENT = HEXDEC("&H0194") Ret 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. wParam = cxExtent (horizontal scroll width) lParam = 0 (must be zero) wParam specifies the number of pixels by which the list box can be scrolled. Windows 95: The wParam parameter is limited to 16-bit values. RETURN: This message does not return a value. NOTES: To respond to the LB.SETHORIZONTALEXTENT message, the list box must have been defined with the WS.HSCROLL style.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Sept 29, 2021 4:45:13 GMT -5
Hi, thanks for the very quick help.
Walt, thank you, I have a horizontal scroll bar so the user can see the whole line if they wish.
Thank you all.
|
|
|
Post by Brandon Parker on Sept 29, 2021 17:19:25 GMT -5
Just a small note, _LB_SETHORIZONTALEXTENT is a recognized Windows constant, so one could use _LB_SETHORIZONTALEXTENT instead of HEXDEC("&H0194"). Both equate to a decimal value of 404.
Another option would be to add a tooltip to the ListBox and track which item the mouse is over, but this is definitely not something that is very easily accomplished with little API experience.
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 30, 2021 8:53:26 GMT -5
Just a small note, _LB_SETHORIZONTALEXTENT is a recognized Windows constant, so one could use _LB_SETHORIZONTALEXTENT instead of HEXDEC("&H0194"). Both equate to a decimal value of 404. Another option would be to add a tooltip to the ListBox and track which item the mouse is over, but this is definitely not something that is very easily accomplished with little API experience. {:0) Brandon Parker Mr. Parker,
A. Where does one find a list of the styles and messages LB recognizes?
|
|
|
Post by Brandon Parker on Sept 30, 2021 16:12:11 GMT -5
Walt, Unfortunately, I do not believe there is one. I normally just try printing one out when it might be in question. I supposed one could grab header files, input them into LB, do some processing, and then try printing them out with the function shown below. You would just push the processed styles/messages/notifications into the testMessageOrStyle() function. The function also returns the value if the style/message/notification is recognized. Also, WS_HSCROLL is also recognized by LB.
result = testMessageOrStyle("WS_HSCROLL") result = testMessageOrStyle("LB_SETHORIZONTALEXTENT") result = testMessageOrStyle("LVM_SETCOLUMNORDERARRAY") End
Function testMessageOrStyle(testString$) On Error GoTo [Error] testMessageOrStyle = Eval("_";testString$) Print "_";testString$;" - ";testMessageOrStyle Exit Function [Error] Print "_";testString$;" - Not recognized by LB!" End Function
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Sept 30, 2021 17:53:57 GMT -5
That's what I thought.
Thanks, for the function, it might come in handy.
I have most of the header files. It is about as easy just add a dot and translate from hex to dec.
Thank you.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Oct 8, 2021 0:21:02 GMT -5
You could do something like this curly. You can use single or double clicks in the listbox In this case double click to view extra long text....single for other uses - put singleclick code within [SingleClickAction] module for other actions eg add up total etc. You could probably set it to scroll and display extra long text as you scroll.
I found this at Alyce's Restaurant
Hope it helps
a$(1) = "This is ................................data no.1":a$(2) = "This is................................ data no.2":a$(3) = "This is................................ data no.3":a$(4) = "This is................................ data no.4" a$(5) = "This is................................ data no.5":a$(6) = "This is................................ data no.6":a$(7) = "This is................................ data no.7":a$(8) = "This is................................ data no.8" a$(9) = "This is ................................data no.9":a$(10) = "This is................................ data no.10"
'nomainwin WindowWidth = 250 WindowHeight = 200 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) listbox #1.outf1, a$(), [dummy1],x1, 50, 150,60
open f$ for Window as #1 [showIt2] #1.outf1, "singleClickSelect [SingleClickAction]" wait
[dummy1] WindowWidth = 500 WindowHeight = 45 UpperLeftX=705'int((DisplayWidth-WindowWidth)/2) UpperLeftY=485'int((DisplayHeight-WindowHeight)/2) BackgroundColor$ = "darkred" textbox #inf1.tb, 10, 10, 450, 25 stylebits #inf1.ok1, _BS_DEFPUSHBUTTON, 0, 0, 0 button #inf1.ok1, "OK", [OK1],UR, 5, 10, 30, 25 on error goto [OK1] open " " for Window_popup as #inf1 #1.outf1, "selection? selected$" #inf1.tb,selected$
wait
[OK1] close #inf1 #1.outf1,"select 0" wait
[SingleClickAction] calldll #user32, "GetDoubleClickTime", delay as ulong #1.outf1, "selectionindex? index" wait
|
|