|
|
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
Добрый день ALL! Помогите разобраться со флажками функции pDC->DrawText(const CString& tr, LPRECT lpRect, UINT nFormat ) Что делаю (код в OnPrint): strText=pClaimInfo->m_FIO+pClaimInfo->m_Adress; pDC->DrawText(strText,rect,DT_CENTER); pClaimInfo->m_FIO pClaimInfo->m_Adress содержат текст с ФИО и адресом клиента. Область вывода (задаётся в rect) явно недостаточна для вывода строки целиком. Без обрезаний. Пытаюсь заставить функцию сделать перенос Хоть какой-нибудь... Результаты: Если используется флажок DT_CENTER текст выводится в указанном прямоугольнике. Но, разумеется, то что не умещается в рамках одной строки аккуратненько обрезается. При попытках встановить прочие флажки: 1)DT_WORD_ELLIPSIS 2)DT_WORDBREAK текст просто не рисуется.Просто вообще ничего не рисуется на Листе. Куда посмотреть? подскажите пожалуйста. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.08.2006, 17:16 |
|
||
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
Попробуй DT_CALCRECT : If the DT_CALCRECT flag is specified, the rectangle specified by lpRect will be updated to reflect the width and height needed to draw the text. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.08.2006, 17:44 |
|
||
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
someonealexПопробуй DT_CALCRECT : If the DT_CALCRECT flag is specified, the rectangle specified by lpRect will be updated to reflect the width and height needed to draw the text. спасибо но... Как говаривал герой "Следствие ведут колобки": "Ни-и-ичего не понимаю" Код: CString strText("TEST"); //strText=pClaimInfo->m_FIO+pClaimInfo->m_Adress; pDC->Rectangle(&rect); pDC->DrawText(strText,&rect,DT_CENTER); Эффект - Нарисован прямоугольник, по центру к верхней грани прижат текст "TEST" CString strText("TEST"); //strText=pClaimInfo->m_FIO+pClaimInfo->m_Adress; pDC->Rectangle(&rect); pDC->DrawText(strText,&rect,DT_EXTERNALLEADING|DT_CENTER|DT_WORDBREAK|DT_CALCRECT); Эффект - Нарисован прямоугольник, текста нет... куда делся? Ни-и-ичего не понимаю... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.08.2006, 17:55 |
|
||
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
Есть еще такая вещь как DT_SINGLELINE, без нее текст может не центроваться msdnIt formats text by expanding tabs into appropriate spaces, aligning text to the left, right, or center of the given rectangle, and breaking text into lines that fit within the given rectangle. The type of formatting is specified by nFormat. This member function uses the device context's selected font, text color, and background color to draw the text. Unless the DT_NOCLIP format is used, DrawText clips the text so that the text does not appear outside the given rectangle. All formatting is assumed to have multiple lines unless the DT_SINGLELINE format is given. If the selected font is too large for the specified rectangle, the DrawText member function does not attempt to substitute a smaller font. If the DT_CALCRECT flag is specified, the rectangle specified by lpRect will be updated to reflect the width and height needed to draw the text. If the TA_UPDATECP text-alignment flag has been set (see CDC::SetTextAlign), DrawText will display text starting at the current position, rather than at the left of the given rectangle. DrawText will not wrap text when the TA_UPDATECP flag has been set (that is, the DT_WORDBREAK flag will have no effect). ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 28.08.2006, 17:59 |
|
||
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
vanomanpDC->DrawText(const CString& tr, LPRECT lpRect, UINT nFormat ) Пытаюсь заставить функцию сделать перенос Хоть какой-нибудь... Насколько я помню, перенос эта функция делать не умеет. Она очень тупо печатает тот набор байт который ей дали. Хочешь сделать перенос - сам разбей на несколько строк (c помощью символа \n :) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.08.2006, 08:33 |
|
||
|
Печать MFC много строк
|
|||
|---|---|---|---|
|
#18+
Решение вопроса: pDC->DrawText(strText,&rect,DT_CENTER|DT_WORDBREAK|DT_NOPREFIX|DT_VCENTER); Это для меня правильно. В моём же случае трабл был в неверном расчёте координат. Поясняю рис 1 ("Квадратиш") top=0-------------| left=0________| |____________| |____________| |--------------------right=10,bottom=15 Чтобы нарисовать сей фигур формируем CRect следующего содержимого CRect rect rect.top=0 rect.left=0 rect.right=10 rect.bottom=15 А можно маненько ошибиться: rect.top=15 rect.left=0 rect.right=10 rect.bottom=0 Таким образом мы получили, выражаясь научным термином, "Квадратиум-Опупениум-Перивёртыум" И ежели pDC->Rectangle(&rect) нарисует фигуру при любом варианте координат. То моя pDC->DrawText() пупела от несварения. Спасибо Всем. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 29.08.2006, 09:54 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=33948590&tid=2030616]: |
0ms |
get settings: |
8ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
65ms |
get topic data: |
10ms |
get forum data: |
3ms |
get page messages: |
45ms |
get tp. blocked users: |
1ms |
| others: | 200ms |
| total: | 354ms |

| 0 / 0 |
