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. Display multi line colors in Rich edit control using VC++

Display multi line colors in Rich edit control using VC++

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 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.
  • K Offline
    K Offline
    K narasimharao
    wrote on last edited by
    #1

    I have a static control(derived from CStatic) and rich edit controls and it contains two lines. I want to set the color of the first line to blue and the second line to red. Currently I am using the CDialog::OnCtlColor and using the SetTextColor function to set the color. However it sets the color for the whole static control i.e. both the lines. Can someone help? knarasimharao

    A 1 Reply Last reply
    0
    • K K narasimharao

      I have a static control(derived from CStatic) and rich edit controls and it contains two lines. I want to set the color of the first line to blue and the second line to red. Currently I am using the CDialog::OnCtlColor and using the SetTextColor function to set the color. However it sets the color for the whole static control i.e. both the lines. Can someone help? knarasimharao

      A Offline
      A Offline
      Anilkumar K V
      wrote on last edited by
      #2

      Just an out line of procedure. customizee as you like:) HWND hRichEdit = NULL; CHARFORMAT* cf = NULL; hRichEdit = (HWND)GetDlgItem (IDC_RICHEDIT); CHARRANGE cr; cr.cpMin = 0; // set strating char position cr.cpMax = -1;// end char pos SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM)&cr); cf = new CHARFORMAT; cf->cbSize = sizeof(CHARFORMAT); cf->dwMask = CFM_COLOR |CFM_BOLD|CFM_FACE|CFM_SIZE|CFM_ITALIC; cf->dwEffects = CFE_BOLD; cf->crTextColor = RGB(255,0,0); cf->yHeight = 160; strcpy ( cf->szFaceName, "Ariel"); SendMessage( (HWND) hRichEdit, SCF_SELECTION, (WPARAM) SCF_ALL, (LPARAM) cf); :) All the best AnilFirst@gmail.com

      O 1 Reply Last reply
      0
      • A Anilkumar K V

        Just an out line of procedure. customizee as you like:) HWND hRichEdit = NULL; CHARFORMAT* cf = NULL; hRichEdit = (HWND)GetDlgItem (IDC_RICHEDIT); CHARRANGE cr; cr.cpMin = 0; // set strating char position cr.cpMax = -1;// end char pos SendMessage(hRichEdit, EM_EXSETSEL, 0, (LPARAM)&cr); cf = new CHARFORMAT; cf->cbSize = sizeof(CHARFORMAT); cf->dwMask = CFM_COLOR |CFM_BOLD|CFM_FACE|CFM_SIZE|CFM_ITALIC; cf->dwEffects = CFE_BOLD; cf->crTextColor = RGB(255,0,0); cf->yHeight = 160; strcpy ( cf->szFaceName, "Ariel"); SendMessage( (HWND) hRichEdit, SCF_SELECTION, (WPARAM) SCF_ALL, (LPARAM) cf); :) All the best AnilFirst@gmail.com

        O Offline
        O Offline
        Owner drawn
        wrote on last edited by
        #3

        anilFirst wrote:

        CHARFORMAT* cf = NULL;

        Won't this work... CHARFORMAT cf;

        Love Forgives--Love Gives--Jesus is Love :)

        --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

        A 1 Reply Last reply
        0
        • O Owner drawn

          anilFirst wrote:

          CHARFORMAT* cf = NULL;

          Won't this work... CHARFORMAT cf;

          Love Forgives--Love Gives--Jesus is Love :)

          --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

          A Offline
          A Offline
          Anilkumar K V
          wrote on last edited by
          #4

          >>Won't this work... >>CHARFORMAT cf; It will....Carry on AnilFirst@gmail.com

          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