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. CRichEditCtrl Font related query

CRichEditCtrl Font related query

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelp
8 Posts 2 Posters 0 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.
  • H Offline
    H Offline
    harsha_1234
    wrote on last edited by
    #1

    hi all, I have a CRichEditCtrl created on CView derived class. After Creating the Rich edit control it's default font is something different than what i want. and it's bold also. so to chnge the font i am selecting all the data present in control and then applying new font to it. but when i paste the data that is not compatible with mine font again i need to select all the data and then apply font on it!! so my question is that is there any way to change the clipboard data's font so that my control will receive data in compatible font only.. or is there any way that whatever font i want my rich edit control to have i should tell it before creation as some parameter..(i think this shouls be the way:-)) means if i want that my rich edit control should have only this font say "courier new" and it is going to be fix for all it's lifetime then i should create rich edit that starts with this font only?? if anybody know's please reply.. Thanks and Regards Harshal shete

    M 1 Reply Last reply
    0
    • H harsha_1234

      hi all, I have a CRichEditCtrl created on CView derived class. After Creating the Rich edit control it's default font is something different than what i want. and it's bold also. so to chnge the font i am selecting all the data present in control and then applying new font to it. but when i paste the data that is not compatible with mine font again i need to select all the data and then apply font on it!! so my question is that is there any way to change the clipboard data's font so that my control will receive data in compatible font only.. or is there any way that whatever font i want my rich edit control to have i should tell it before creation as some parameter..(i think this shouls be the way:-)) means if i want that my rich edit control should have only this font say "courier new" and it is going to be fix for all it's lifetime then i should create rich edit that starts with this font only?? if anybody know's please reply.. Thanks and Regards Harshal shete

      M Offline
      M Offline
      Mahesh Kulkarni
      wrote on last edited by
      #2

      harsha_1234 wrote:

      is there any way that whatever font i want my rich edit control to have

      I have solution for this..... Declare CFont *c; reference in the class . If you want if for lifetime you have to add the following code in OnInitDialog where m_pRichEdit is variable of RichEditCtrl .... c=new CFont(); c->CreatePointFont(180,"Monotype Corsiva"); m_pRichEdit.SetEventMask(m_pRichEdit.GetEventMask() |ENM_CHANGE); Then Just make method for RichEditControl Text Change. Write Following statement in it. GetDlgItem(IDC_RICHEDIT21)->SetFont(c); You can take font name as parameter and provide it to the CreatePointFont method of CFont. You will get the desired output. Hope This will help you.

      The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

      H 1 Reply Last reply
      0
      • M Mahesh Kulkarni

        harsha_1234 wrote:

        is there any way that whatever font i want my rich edit control to have

        I have solution for this..... Declare CFont *c; reference in the class . If you want if for lifetime you have to add the following code in OnInitDialog where m_pRichEdit is variable of RichEditCtrl .... c=new CFont(); c->CreatePointFont(180,"Monotype Corsiva"); m_pRichEdit.SetEventMask(m_pRichEdit.GetEventMask() |ENM_CHANGE); Then Just make method for RichEditControl Text Change. Write Following statement in it. GetDlgItem(IDC_RICHEDIT21)->SetFont(c); You can take font name as parameter and provide it to the CreatePointFont method of CFont. You will get the desired output. Hope This will help you.

        The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

        H Offline
        H Offline
        harsha_1234
        wrote on last edited by
        #3

        Hi i Tried this it is applying the font but the boldness of the font is still there i want to disable the boldness also..

        M 1 Reply Last reply
        0
        • H harsha_1234

          Hi i Tried this it is applying the font but the boldness of the font is still there i want to disable the boldness also..

          M Offline
          M Offline
          Mahesh Kulkarni
          wrote on last edited by
          #4

          For more Font Specification you can use the CreatePointFontIndirect() API. This API uses pointer of the LOGFONT.

          The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

          H 1 Reply Last reply
          0
          • M Mahesh Kulkarni

            For more Font Specification you can use the CreatePointFontIndirect() API. This API uses pointer of the LOGFONT.

            The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

            H Offline
            H Offline
            harsha_1234
            wrote on last edited by
            #5

            Hey i am sorry, it's boldness is also disabled now. but now the only problem i am facing is that whenever i paste saomething in the control it's font remains same.. so i am thinking of something like this whenever user say's Paste. i will change clipboeard data's font and boldness as i want. Is this a good approach??? please Guide me as i am not very much familiar with this control Thanks and Regards Harshal

            M 1 Reply Last reply
            0
            • H harsha_1234

              Hey i am sorry, it's boldness is also disabled now. but now the only problem i am facing is that whenever i paste saomething in the control it's font remains same.. so i am thinking of something like this whenever user say's Paste. i will change clipboeard data's font and boldness as i want. Is this a good approach??? please Guide me as i am not very much familiar with this control Thanks and Regards Harshal

              M Offline
              M Offline
              Mahesh Kulkarni
              wrote on last edited by
              #6

              Create a eventhandler for RicheditCtrl on EN_CHANGE Write Following statement in it. GetDlgItem(IDC_RICHEDIT21)->SetFont(c); This will give the desired output.

              The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

              H 1 Reply Last reply
              0
              • M Mahesh Kulkarni

                Create a eventhandler for RicheditCtrl on EN_CHANGE Write Following statement in it. GetDlgItem(IDC_RICHEDIT21)->SetFont(c); This will give the desired output.

                The secret of life is not enjoyment but education through experience. - Swami Vivekananda.

                H Offline
                H Offline
                harsha_1234
                wrote on last edited by
                #7

                Thank You very much for your help. it is working very fine. Thank's.

                H 1 Reply Last reply
                0
                • H harsha_1234

                  Thank You very much for your help. it is working very fine. Thank's.

                  H Offline
                  H Offline
                  harsha_1234
                  wrote on last edited by
                  #8

                  But Apart from this i have another query i am doing undo redo also. it is working fine but in undo as well as redo there is one small problem that whenever i undo/redo then after every undo/redo operation it selects some text and then on next undo/redo it undoes/redoes the character that was typed. how i can fake the middle selection between two operations?? undo code is like this if (m_rich.CanUndo()) { m_rich.Undo(); } Thanks and regards Harshal

                  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