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. Background text color in RichEditCtrl

Background text color in RichEditCtrl

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpcsharpvisual-studiolounge
3 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.
  • A Offline
    A Offline
    anwar1026
    wrote on last edited by
    #1

    Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.

    P S 2 Replies Last reply
    0
    • A anwar1026

      Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      Use method AfxInitRichEdit2 instead of AfxInitRichEdit to initialize controls.

      Prasad Notifier using ATL | Operator new[],delete[][^]

      1 Reply Last reply
      0
      • A anwar1026

        Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.

        S Offline
        S Offline
        Scott Holt
        wrote on last edited by
        #3

        Try a couple of things: 1 - use the following message: ::SendMessage( m_hwndText, //Handle to edit control. EM_SETBKGNDCOLOR, 0, clrBackground) ; //e.g., ULONG clrBackground = RGB(255, 0, 0) ; 2 - Also, I seem to remember some time ago having to first put some text into a rich edit before I could change the background. You first have to select the text using CHARRANGE, then use CHARFOMAT2 to format the text. I have a vague recollection of putting a single space character into the rich edit to get it to work, but you may not have to. Scott

        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