Hi Martin,
On Tuesday, 29 April 1997 at 22:17:20, Martin Maat confused me
talking about: Owner draw listboxes to Simon Huggins
SH>> I have managed to create code which deals with
SH>> putting items wider than the list box onto two lines but
SH>> not yet managed to get this working for more than that.
SH>> i.e. to recognise how many then loop through for each one.
SH>> I tried to set the height variable passed in
SH>> OnmeasureItem and then inspect it in OnDrawItem but it
SH>> didn't work :(
MM> It does work, be carefull not to rely on the
MM> Items[Index].Object value though, you cannot get to it for
MM> some from within MeasureItem for some reason. Setting Height
MM> for an item however should work just fine. The maximum
MM> height is 255 pixels. What is your problem exactly?
Well, I've got long lines of text and I'm trying to find a way of displaying
them in a listbox.
I have worked out a clumsy way of doing it. Find the first word by checking
for spaces, grab it, change the spaces to asterisks * (so that I can use
pos to check for the next space) and see if the temporary line plus this new
word exceeds the boundary.
Repeat until it does then do this a second time.
I had put that in the OnDrawItem bit and in the OnMeasureItem, I checked
to see if items[index] was bigger than the limit. if it was, then it was
two lines long.
At the moment I want to be able to tell if it is 1,2,3,4,5 etc lines long in
onMeasureItem and then refer to that to iterate the correct number of times
in OnDrawItem but I can't seem to access height in OnDrawItem
SH>> Is there any good reason why OnDrawItem can't be
SH>> empty?
MM> Well, you do want something to be drawn, right? The
MM> beauty of OwnerDraw mode is that nothing will be drawn
MM> unless you want it to.
Or even if you want it too it will go off the edge ;)
SH>> Is there a much more elegant solution (there must be
SH>> somewhere)
MM> This is as elegant as it gets. Did you set the draw
MM> mode to OwnerDrawVariable? You need to do this in order to
MM> be able to set the height of individual items.
Yep, I worked that out but, I thought that someone *MUST* have some code
somewhere which does something similar.
Thanks for the reply,
bfn,
si.
Fido : 2:440/7.15 or Internet : huggie@dial.pipex.com
Web : http://dialspace.dial.pipex.com/huggie
.!. "We've lost 'em! (BOOM!) Sorry, I was looking at the wrong screen."
--- Terminate 4.00/Pro
---------------
* Origin: Simon's GREEN point: Pointing to a better colour. (2:440/7.15)
|