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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

NickRepinCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.