ShortenString Function

Virtual Tree View

General purpose routine to shorten a Unicode string to a given maximum size.

Pascal
function ShortenString(DC: HDC; const S: WideString; Width: Integer; RTL: Boolean; EllipsisWidth: Integer = 0): WideString;
Description

Adjusts the given string S so that it fits into the given width. DC holds the handle to a valid device context which can be used to determine the width of a string. Of couse, this device context should be set up with the proper values for the current font. EllipsisWidth gives the width (in logical units) of the three points to be added to the shorted string. If this value is 0 then it will be determined implicitely. For higher speed (and multiple entries to be shorted) specify this value explicitely. RTL determines if right-to-left reading is active, which is needed to put the ellipsisis on the correct side. The result is the left part of the string which fits into the given space plus the ellipsisis.

Notes

It is assumed that the string really needs shortage. Check this in advance.

Group
File

VirtualTrees

Links
What do you think about this topic? Send feedback!