Link to home
Start Free TrialLog in
Avatar of gil_mo
gil_mo

asked on

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 )
Avatar of NickRepin
NickRepin

DT_MODIFYSTRING is not required to display a string (but requred if you need to really modify the string)
Avatar of gil_mo

ASKER

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?
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
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gil_mo

ASKER

Adjusted points to 70
Avatar of gil_mo

ASKER

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?!
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
Avatar of gil_mo

ASKER

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.
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
Avatar of gil_mo

ASKER

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...
> 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