![]() |
|
QA: How to emulate DT_END_ELLIPSIS flag of DrawText function?
By Alexander Shargin, May 27, 2002.
QuestionOn desktop platforms DrawText function supports DT_END_ELLIPSIS flag which allows to truncate the string and add ellipsis ("...") to the end of it if it doesn't fit in the specified rect. But this flag is not implemented on Pocket PC. How can I emulate it? AnswerThe main idea is to use CDC::GetTextExtent method to determine text's width. If it's greater than the width of the rect we can truncate the string, append ellipsis to the end of it, call CDC::GetTextExtent method again and repeat this procedure in a loop till the string fits in the rect. Then we can call DrawText to display the string. Here is a sample implementation of DrawTextEndEllipsis function which behaves like desktop version of DrawText with DT_END_ELLIPSIS flag set. DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||