Search

TextRenderer.MeasureText with TextFormatFlags.PathEllipsis | TextFormatFlags.ModifyString flags by MNieto

Closed
as Won't Fix Help for as Won't Fix

1
0
Sign in
to vote
Type: Bug
ID: 620330
Opened: 11/9/2010 5:36:38 PM
Access Restriction: Public
1
Workaround(s)
0
User(s) can reproduce this bug
When used overload of MeasureText(String, Font, Size, TextFormatFlags) with flags TextFormatFlags.PathEllipsis | TextFormatFlags.ModifyString
the resulting string ends with a null char followed by an arbitrary chunk of the original path.
For example, the original string is
d:\\abcd\\efgh\\ijkl\\yzAB\\CDEF\\GHIJ\\KLMN\\OPQR\\STIV\\WXYZ\\test.txt
and the modified string is
d:\\abcd\\efgh\\ijkl\\...\\test.txt\0F\\GHIJ\\KLMN\\OPQR\\STIV\\WXYZ\\test.txt


A possible workaround is:
result = result.Substring(0, result.IndexOf('\0'));
to truncate from the null char.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

 

Steps to reproduce

Create an empty form, add a button and paste the following code on the click event:


string aFileName = "d:\\abcd\\efgh\\ijkl\\yzAB\\CDEF\\GHIJ\\KLMN\\OPQR\\STIV\\WXYZ\\test.txt";
string fileName = String.Copy(aFileName);
TextRenderer.MeasureText(fileName,
this.Font,
this.ClientSize,
TextFormatFlags.PathEllipsis |
TextFormatFlags.ModifyString);
System.Diagnostics.Debug.WriteLine(fileName);

Product Language

English

Operating System

Windows XP

Operating System Language

Spanish

Actual results

d:\\abcd\\efgh\\ijkl\\...\\test.txt\0F\\GHIJ\\KLMN\\OPQR\\STIV\\WXYZ\\test.txt

(The ellipsis position depends on the client area width of the form)

Expected results

d:\\abcd\\efgh\\ijkl\\...\\test.txt

(The ellipsis position depends on the client area width of the form)
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/18/2010 at 6:25 PM
Thank you for reporting this issue. Customer feedback is a critical part of a successful, impactful software product. Unfortunately another part is the reality of schedules and the need to prioritize investments according to the objectives of the product. We have evaluated the issue that you have reported and at this point in the product's lifecycle, it does not meet the criteria to be addressed. This evaluation is carefully done and considers many aspects including the cost of the fix, implications of the change, and the number of reported instances of the issue.

Many customers have found it useful to discuss issues like this in the forums (http://www.microsoft.com/communities/forums/default.mspx) where Microsoft and other members of the community can recommend ways of achieving the behavior you are interested in.

Thank you,
The Windows Forms Product Team
Posted by Microsoft on 11/9/2010 at 10:06 PM
Thanks for your feedback.
We are routing this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/9/2010 at 6:26 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by MNieto on 11/9/2010 at 5:37 PM
A possible workaround is:
result = result.Substring(0, result.IndexOf('\0'));
to truncate from the null char.