Joe!

Yes, i understand the concept - but for my need the "condensed" feature of DrawString() isn't usable, because I have no chance to calculate the starting point of the next string.

When I want to print "xxxyyyzzz" where "yyy" is red and the rest black colored, I have to use three DrawString(). I really would like to use the condensed version, but I can't calculate the starting point of the "yyy" and "zzz" string.

Nevertheless I solved the problem (almost) perfect. Here is the code for anybody who is interested in doing such Listbox multistyle things. The only bad thing: There are conditions where the "..." extension of condensed strings are not shown (depends on the column width) and only the last part of the string is condensed when needed ...

CellTextPaint() [...of a Listbox]
  if (column = 1) then
    dim aStart, aLength, anOffset As Integer = 0
    dim aString, aSubString As String
    dim aSavedColor As Color

    aStart = me.CellTag(row, 0 ) + 1 // ...was stored 0-based!
    aLength = me.CellTag(row, 1 )
    aString = me.Cell(row, 1)
    aSavedColor = g.ForeColor

    aSubString = aString.Left(aStart - 1)
g.DrawString(aSubString, 0, 11, (me.Column(1).WidthActual - 3), true)
    anOffset = g.StringWidth(aSubString)
    g.ForeColor = RGB(255, 0, 0)

    aSubString = aString.Mid(aStart, aLength)
g.DrawString(aSubString, anOffset, 11, (me.Column(1).WidthActual - 3 - anOffset), true)
    anOffset = anOffset + g.StringWidth(aSubString)
    g.ForeColor = aSavedColor

    aSubString = aString.Mid((aStart + aLength), len(aString))
g.DrawString(aSubString, anOffset, 11, (me.Column(1).WidthActual - 3 - anOffset), true)

    return true
  else
    return false
  end
end of CellTextPaint

Best,
Marcel

On 09.05.2006, at 22:03, [EMAIL PROTECTED] wrote:

On May 09, 2006, at 19:09 UTC, Marcel wrote:

StringWidth() can not return the width of a condensed DrawString(...,
true). This is very frustrating and not well designed - or do I miss
something?

Maybe you do; "condensed" isn't a drawing style; it's a special operation made to fit a string into a specified width (often by removing characters, in addition to changing the character spacing). So, for most purposes, the width of that condensed string is the width you specify.

Best,
- Joe

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to