I've got an old VB6 program that hasn't changed in a while but now has a new behavior. I'm thinking a common component was upgraded from underneath it. Here are the details.
I've got a standard ListView control in SmallIcon mode. Code snippet:
'setup the listview
With lvwMap
.Appearance = ccFlat
.BackColor = vbBlack
.BorderStyle = ccNone
.Font.Name = "Arial"
.Font.Bold = True
.Font.Size = 9
.ForeColor = vbYellow
.LabelEdit = lvwManual
.LabelWrap = True
.OLEDropMode = ccOLEDropManual
.PictureAlignment = lvwTopLeft
.TextBackground = lvwOpaque
.View = lvwSmallIcon
End With
Most ListItems that are added have both an SmallIcon and a Caption (Text). The TextBackground is set as Opaque, meaning the text is rendered in an enclosing colored rectangle.
Some items though may not have a caption provided or the user can change it such that there is no caption. This used to be fine, with just the SmallIcon showing. But now any ListItem that has an empty Text property renders a fairly wide enclosing rectangle with no text inside (as if a user keyed in a bunch of spaces perhaps).
The code to add a ListItem is straight-forward:
Set oLI = lvwMap.ListItems.Add(lvwMap.ListItems.Count + 1, Key:=sKey)
oLI.SmallIcon = sIcon
oLI.Text = sCaption
I stopped the debugger here and thried the following in the immediate window:
oLI.Text= "AAAAAAA"
?oLI.Width
100.0063
oLI.Text= "AAAAAA"
?oLI.Width
91.99371
oLI.Text= "AAAAA"
?oLI.Width
84.0189
oLI.Text= "AAAA"
?oLI.Width
76.0063
oLI.Text= "AA"
?oLI.Width
60.0189
oLI.Text= "A"
?oLI.Width
52.0063
oLI.Text= ""
?oLI.Width
96.00001
As you can see the ListItem.Width correctly recalculates until the Text becomes empty and then jumps to 96 pixels.
Does anyone know any way to compensate for this behavior? Some windows message I can use to configure the default empty wdith? Any information on a change to ListView behavior might be helpful as well.