Measure CRichEditCtrl height
-
Is there a way to measure richedit height? I should put CRichedit into fixed width window, but I should avoid vertical scroll. So, I should calculate the CRichEdit(with text) height for a specified width. Is it possible?
Pavel Sokolov
-
Is there a way to measure richedit height? I should put CRichedit into fixed width window, but I should avoid vertical scroll. So, I should calculate the CRichEdit(with text) height for a specified width. Is it possible?
Pavel Sokolov
You could use GetWindowPlacement[^] to determine the height; the rcNormalPosition member of the WINDOWPLACEMENT structure has the info you're after. Then SetWindowPlacement[^] to adjust it if needed.
-
Is there a way to measure richedit height? I should put CRichedit into fixed width window, but I should avoid vertical scroll. So, I should calculate the CRichEdit(with text) height for a specified width. Is it possible?
Pavel Sokolov
Pavel Sokolov wrote:
Is there a way to measure richedit height?
You mean something like
GetWindowRect()
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
-
You could use GetWindowPlacement[^] to determine the height; the rcNormalPosition member of the WINDOWPLACEMENT structure has the info you're after. Then SetWindowPlacement[^] to adjust it if needed.
I need it before creation of actual control.
Pavel Sokolov
-
Pavel Sokolov wrote:
Is there a way to measure richedit height?
You mean something like
GetWindowRect()
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
Actually I want to display richedit inside the other control item. So, I know width, but I should set the height too. I deen something like: int m_Height = m_RichEditControl.CalculateControlHeightForThisWidth( m_intWidth ) :)
Pavel Sokolov
-
I need it before creation of actual control.
Pavel Sokolov
Okay so instead of measuring it, it should be calculated. What is known to base the calculation on? The number of lines that are going to be in the control? If so, you should multiply the number of lines with the height of a line, depending on the font, and add an offset of a few pixels for the border.
-
Okay so instead of measuring it, it should be calculated. What is known to base the calculation on? The number of lines that are going to be in the control? If so, you should multiply the number of lines with the height of a line, depending on the font, and add an offset of a few pixels for the border.
Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.
Pavel Sokolov
-
Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.
Pavel Sokolov
-
The text in the control. I want to fit richedit into item of another control without vertical scrollbar. The main idea is to build messages archive (history for IM). There can be a lot of messages and they are in rtf. Currently I'm trying to insert RichEdit into ListBoxItem and I need width and height for MeasureItem().
Pavel Sokolov
-
I have found something - Calculating a Rich Edit Control Minimum Size[^]. But this way will require a hidden window with richedit control to measure the size.
Pavel Sokolov
-
Actually I want to display richedit inside the other control item. So, I know width, but I should set the height too. I deen something like: int m_Height = m_RichEditControl.CalculateControlHeightForThisWidth( m_intWidth ) :)
Pavel Sokolov
На самом деле, варианта у тебя два: - действительно создать скрытый рич-едит, вызывать у него RequestResize и ловить EN_REQUESTRESIZE. Вариант вполне нормальный. - если делать совсем все правильно, то в твоем случае не надо встраивать рич-едиты в лист-контрол. Тебе надо копать в сторону windowless-ричедита, внимательно изучив ITextHost/ITextServices. ЗЫ: Как жизнь вообще? Чем занимаешься? Твой логотип SWR оказался очень живуч :))
Regards, Nikolay
-
На самом деле, варианта у тебя два: - действительно создать скрытый рич-едит, вызывать у него RequestResize и ловить EN_REQUESTRESIZE. Вариант вполне нормальный. - если делать совсем все правильно, то в твоем случае не надо встраивать рич-едиты в лист-контрол. Тебе надо копать в сторону windowless-ричедита, внимательно изучив ITextHost/ITextServices. ЗЫ: Как жизнь вообще? Чем занимаешься? Твой логотип SWR оказался очень живуч :))
Regards, Nikolay
Мама дорогая, какие люди! Да ничего, всё тем же и занимаюсь. Ты то как? Я вас пытался найти как-то по соцсетям - да так и не нашёл. А что мне даст безоконный ричедит? На самом деле у всех подобные контроллы есть (да почти во все месенджерах история сообщений), а тут такие сложности... Может вообще одним ограничиться и догружать нужное по кликам на скроллбарах, так наверняка будет мелькать противно.
Pavel Sokolov
-
Мама дорогая, какие люди! Да ничего, всё тем же и занимаюсь. Ты то как? Я вас пытался найти как-то по соцсетям - да так и не нашёл. А что мне даст безоконный ричедит? На самом деле у всех подобные контроллы есть (да почти во все месенджерах история сообщений), а тут такие сложности... Может вообще одним ограничиться и догружать нужное по кликам на скроллбарах, так наверняка будет мелькать противно.
Pavel Sokolov
Ну, смотря какой функционал тебе от этого списка нужен. Если просто "мертвый" список, то я бы ограничился первым вариантом. Т.е. создал бы невидимый ричедит, через него бы вычислял высоту каждого айтема в списке, через него же рендерил в битмап в памяти сам текст айтема. Потом при отрисовке айтема просто выводил бы уже готовый битмап. Если же требуется какая-то интерактивность от списка, например, если ты хочешь, чтобы можно было бы кликнуть на линки, которые могуть быть в тексте, менять курсор, когда мышка поверх таких линков и т.п., то тут уже без безоконного ричедита обойтись будет трудно. ЗЫ: я есть тут: http://vkontakte.ru/id1216693[^] или тут http://ru-ru.facebook.com/profile.php?id=1610591135[^]
Regards, Nikolay