Bug: DrawText( ) with DT_PATH_ELLIPSIS?

DrawText with DT_PATH_ELLIPSIS does not seem to perform the replacement with ellipses when the input string does not contain a backslash... instead, system attempts to draw the *whole* string and clips it. is is this a known bug?? I use the DevStudio 6.0.

( my format flags are DT_PATH_ELLIPSIS | DT_MODIFYSTRING of course, as requested in the doc )
gil_moAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
NickRepinConnect With a Mentor Commented:
DrawText/DT_PATH_ELLIPSIS realy doesn't shorten a string if it doesn't contain backslashes.
It's not a bug, but "feature".

As to DT_MODIFYSTRING, it works as follows.

char txt[]="long string";
DrawText( txt,...DT_END_ELLIPSIS )

1) If string is fit into rectangle, it is not modified.

2) If string doesn't fit, it will be displayed as "long str..."

a) With DT_MODIFYSTRING:
txt buffer will be modified as well and will contain "long str..."

b) Without DT_MODIFYSTRING:
txt buffer will not be modified and will contain "long string"

0
 
NickRepinCommented:
DT_MODIFYSTRING is not required to display a string (but requred if you need to really modify the string)
0
 
gil_moAuthor Commented:
This is not so reading the msdn doc:
"Replaces part of the *given* string...", then: "The *given* string is not modified unless the DT_MODIFYSTRING flag is specified".

However, the question remains: is this a known bug or am I doing something wrong?
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
LischkeCommented:
I think this is not a bug. You specified to shorten a path. This is done by shorten the last sub-path. If you don't pass backslashes with the string then it is assumed that the string contains a file name without a path which can be shortend. If you like this shortend too then you can use DT_END_ELLIPSIS (perhaps conditionally: only if there's no path part in the string?).

Ciao, Mike
0
 
gil_moAuthor Commented:
Adjusted points to 70
0
 
gil_moAuthor Commented:
Lischke,
The docs definitely claim that this option shortens ANY string. The backslashes are mentioned with an 'if' at the end.

And in any case, I need to shorten a string in its middle. Does that mean I have to write my own shortening algorithm?!
0
 
LischkeCommented:
Yes, I see. But I think it makes no sense to discuss if this is an implementation or a documentation bug. I'm afraid you will to write your own shortening algorithm in your special case (but relatively easy, GetCharWidth32 or GetCharWidth if you need Unicode on Win9x).

Ciao, Mike
0
 
gil_moAuthor Commented:
Yes, looping on GetCharWidth32 and replacing a character in mid-string until the result fits the rect... pretty ugly but I guess Microsoft leaves me no choice :(

I shall leave this Q open for a chance that there IS some way to implement this using DrawText. If not, I'll grant the points to NickRepin.
0
 
mikeblasCommented:
Looks like you found a documentation bug. I'll report it to the documentation team.

 > pretty ugly

What's ugly about it? People code loops every day!

 > but I guess Microsoft leaves me no choice :(

Yeah. Microsoft very often forces people to write some code all by themselves.

..B ekiM
0
 
gil_moAuthor Commented:
Thanks for reporting, and thanks for the sting, mike.

The documentation team should also explain what the difference is between DT_END_ELLIPSIS and DT_WORD_ELLIPSIS...
0
 
mikeblasCommented:
> Thanks for reporting,

Sure.

 > and thanks for the sting, mike.

It's just that I think you're overreacting. You found a flag that might've made work easier for you, but it turns out not to. I'm sorry you had to waste time with it, but that's what hpapens in the face of a documentation bug. In the meantime, it's really not so hard to solve the problem for yourself.

 > The documentation team should also explain what the
 > difference is between DT_END_ELLIPSIS and DT_WORD_ELLIPSIS...

You can write to the documentation team yourself at vcdocs@microsoft.com . That alias is really meant for feedback about the VC++ documentation, but the folks there are happy to pass bugs on to the SDK team.

..B ekiM
0
All Courses

From novice to tech pro — start learning today.