ListIconGadget + Wordwrap

Just starting out? Need help? Post your questions and find answers here.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 641
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

ListIconGadget + Wordwrap

Post by captain_skank »

Morning All,

I use the followng call to wordwrap text in a listicongadget :

SendMessage_(GadgetID(#fld_8010_t9_table), #EM_SETTARGETDEVICE, #Null, 0)

This will wordwrap text that is longer than the width of the column in the listicongadget, except if the text contains carriage returns, when it will just ignore everything after that point.

Anybody know a way around this or if this is even the right call ??

The listicongadget could really do with upgrading to include wordwrapping,rowheight and column sorting options imho. :oops:

Cheers
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: ListIconGadget + Wordwrap

Post by IdeasVacuum »

According to MSDN, you do have the correct SendMessage.

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

It sounds as though the ListIcon cells are being filled/updated programmatically in your app? If that is the case, then perform a String Replace first and replace the #CRLF$ chars with space chars.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: ListIconGadget + Wordwrap

Post by RASHAD »

captain_skank Hi
I think what you need is to increase the line height
Then you can insert word wrap text and at the same time you can use chr(13) as a Return

Code: Select all

If OpenWindow(0, 0, 0, 640, 440,"WordWrap Demo",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  ListIconGadget(0, 10, 10, 620, 420, "Column 0", 220,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines)
  LoadFont(0, "Tahoma", 12 )
  SetGadgetFont(0, FontID(0))
  Texth = SendMessage_(GadgetID(0), #LVM_GETITEMSPACING, 1, 0) >> 16 - 4
  AddGadgetColumn(0, 1, "Column 1", 150)
  imageList = ImageList_Create_(1, 5*Texth, #ILC_COLOR32 | #ILC_MASK, 0, 0) ;for 5 lines
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL, imageList)
  
  For x=1 To 4 
    AddGadgetItem(0,-1, "This is a wordwrap text demonstration in a ListIcon Gadget  " + Chr(13) + "This is a separate line" + Chr(10) + "Line 1" + Chr(13) + "Line 2" + Chr(13) + "Line 3" + Chr(13) + "Line 4" + Chr(13) ) 
  Next
  
 
  Repeat 
    event = WaitWindowEvent() 
    Select event 
      Case #PB_Event_Gadget 
        Select EventGadget() 
          Case 0

        EndSelect 
    EndSelect 
  Until event = #PB_Event_CloseWindow 
EndIf 
End 

Egypt my love
MarcoAb
New User
New User
Posts: 5
Joined: Wed Aug 10, 2022 6:40 am

Re: ListIconGadget + Wordwrap

Post by MarcoAb »

Hi, I use this trick often. Thanks. Is there a possibility to display more than 255 characters in a single column?

Thanks in advance

Marco
User avatar
jacdelad
Addict
Addict
Posts: 2013
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: ListIconGadget + Wordwrap

Post by jacdelad »

On Windows the ListIconGadget is basically a ListView-Control. According to Microsoft:
The Text property allows you to change the text displayed for the item. The text of the ListViewItem should not exceed 259 characters or unexpected behavior could occur.
https://learn.microsoft.com/en-us/dotne ... wItem_Text
This applies to the ListViews created via API and the .net-Framework.

Quoting Peter Huang from Microsoft about the cause:
Why the length of the text of listview item is limited to 259 character is
because that the listview is design for display collection of objects like
files and not for general purpose control. So it is similar to the filename
length limitation in the windows file system's MAX_PATH.
https://bytes.com/topic/visual-basic-ne ... lumn-sizes
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
MarcoAb
New User
New User
Posts: 5
Joined: Wed Aug 10, 2022 6:40 am

Re: ListIconGadget + Wordwrap

Post by MarcoAb »

Ok . Got it.
Thanks
User avatar
jacdelad
Addict
Addict
Posts: 2013
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: ListIconGadget + Wordwrap

Post by jacdelad »

But to be honest, in my opinion, 259 characters is a bit low for a control with so much power and customizations.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply