Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Measure CRichEditCtrl height

Measure CRichEditCtrl height

Scheduled Pinned Locked Moved C / C++ / MFC
question
13 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pavel Sokolov
    wrote on last edited by
    #1

    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

    L D 2 Replies Last reply
    0
    • P 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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      P 1 Reply Last reply
      0
      • P 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

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • L Lost User

          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.

          P Offline
          P Offline
          Pavel Sokolov
          wrote on last edited by
          #4

          I need it before creation of actual control.

          Pavel Sokolov

          L 1 Reply Last reply
          0
          • D David Crow

            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

            P Offline
            P Offline
            Pavel Sokolov
            wrote on last edited by
            #5

            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

            N 1 Reply Last reply
            0
            • P Pavel Sokolov

              I need it before creation of actual control.

              Pavel Sokolov

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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.

              P 1 Reply Last reply
              0
              • L Lost User

                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.

                P Offline
                P Offline
                Pavel Sokolov
                wrote on last edited by
                #7

                Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.

                Pavel Sokolov

                L 1 Reply Last reply
                0
                • P Pavel Sokolov

                  Nothing. I have only width of the control. The lines can have different styles and fonts and even with pictures.

                  Pavel Sokolov

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  So what exactly decides then how high you want it to be?

                  P 2 Replies Last reply
                  0
                  • L Lost User

                    So what exactly decides then how high you want it to be?

                    P Offline
                    P Offline
                    Pavel Sokolov
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • L Lost User

                      So what exactly decides then how high you want it to be?

                      P Offline
                      P Offline
                      Pavel Sokolov
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      • P 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

                        N Offline
                        N Offline
                        Nikolay Denisov
                        wrote on last edited by
                        #11

                        На самом деле, варианта у тебя два: - действительно создать скрытый рич-едит, вызывать у него RequestResize и ловить EN_REQUESTRESIZE. Вариант вполне нормальный. - если делать совсем все правильно, то в твоем случае не надо встраивать рич-едиты в лист-контрол. Тебе надо копать в сторону windowless-ричедита, внимательно изучив ITextHost/ITextServices. ЗЫ: Как жизнь вообще? Чем занимаешься? Твой логотип SWR оказался очень живуч :))

                        Regards, Nikolay

                        P 1 Reply Last reply
                        0
                        • N Nikolay Denisov

                          На самом деле, варианта у тебя два: - действительно создать скрытый рич-едит, вызывать у него RequestResize и ловить EN_REQUESTRESIZE. Вариант вполне нормальный. - если делать совсем все правильно, то в твоем случае не надо встраивать рич-едиты в лист-контрол. Тебе надо копать в сторону windowless-ричедита, внимательно изучив ITextHost/ITextServices. ЗЫ: Как жизнь вообще? Чем занимаешься? Твой логотип SWR оказался очень живуч :))

                          Regards, Nikolay

                          P Offline
                          P Offline
                          Pavel Sokolov
                          wrote on last edited by
                          #12

                          Мама дорогая, какие люди! Да ничего, всё тем же и занимаюсь. Ты то как? Я вас пытался найти как-то по соцсетям - да так и не нашёл. А что мне даст безоконный ричедит? На самом деле у всех подобные контроллы есть (да почти во все месенджерах история сообщений), а тут такие сложности... Может вообще одним ограничиться и догружать нужное по кликам на скроллбарах, так наверняка будет мелькать противно.

                          Pavel Sokolov

                          N 1 Reply Last reply
                          0
                          • P Pavel Sokolov

                            Мама дорогая, какие люди! Да ничего, всё тем же и занимаюсь. Ты то как? Я вас пытался найти как-то по соцсетям - да так и не нашёл. А что мне даст безоконный ричедит? На самом деле у всех подобные контроллы есть (да почти во все месенджерах история сообщений), а тут такие сложности... Может вообще одним ограничиться и догружать нужное по кликам на скроллбарах, так наверняка будет мелькать противно.

                            Pavel Sokolov

                            N Offline
                            N Offline
                            Nikolay Denisov
                            wrote on last edited by
                            #13

                            Ну, смотря какой функционал тебе от этого списка нужен. Если просто "мертвый" список, то я бы ограничился первым вариантом. Т.е. создал бы невидимый ричедит, через него бы вычислял высоту каждого айтема в списке, через него же рендерил в битмап в памяти сам текст айтема. Потом при отрисовке айтема просто выводил бы уже готовый битмап. Если же требуется какая-то интерактивность от списка, например, если ты хочешь, чтобы можно было бы кликнуть на линки, которые могуть быть в тексте, менять курсор, когда мышка поверх таких линков и т.п., то тут уже без безоконного ричедита обойтись будет трудно. ЗЫ: я есть тут: http://vkontakte.ru/id1216693[^] или тут http://ru-ru.facebook.com/profile.php?id=1610591135[^]

                            Regards, Nikolay

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups