DrawTextEx does not work

G

Guest

I have a small rectangle into which I want to display a maximum of 2 lines of text. If the text overflows that second line I want to display the ellipse at the end. The problem is the text drawing functions don't draw an ellipse at the end of the text when the text is displayed on two lines, so I have decided to perform 2 seperate DrawText operations to draw it myself. The only problem is, DrawTextEx does not return anything about the draw operation so when I draw that first line of text I do not know where to begin the second

The DrawTextEx() function is documented to have 2 means of providing the information I need, only neither of them work. The first is to look at the uiLengthDrawn member of the DRAWTEXTPARAMS function but it is always incorrect. The value returned is neither the number of characters processed or the total length of the original string. My second attempt was to use the DT_MODIFYSTRING flag but it does not change my string

What must I do to get back the string that was actually displayed? Will it always break the string at a word?
 
D

David Lowndes

Steve,

Your question would be more appropriate in the
microsoft.public.win32.programmer.gdi newsgroup.

If you re-post there, can you also mention which operating systems
this issue applies to, and perhaps show a snippet of stand-alone code
to illustrate your point.

Dave
 
G

Gary Chang

Hi stephen,

Thanks for posting in the community.

From your description, I understand that the DrawTextEx(...) function
doesn't display a two-line string as expected(with an ellipse) in a small
rectangle, please correct me if there is any misunderstand.

First I want to know what's the usage of the DrawTextEx(...) function in
your program, I tested the following code snippet on my side, it seems well:
...
CDC* pdc(this->GetDC());
CRect rc(50,50,220,80);

CString str("TODO: Add your control notification handler code here");
pdc->DrawTextEx(str, &rc, DT_WORDBREAK | DT_END_ELLIPSIS | DT_VCENTER,
NULL);
...


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
G

Gary Chang

Hi stephen,

How is the problem going?
If your problem still persists and you have more concerns on it, please
feel free to reply this message.


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top