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. Rich Edit Coloring

Rich Edit Coloring

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 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.
  • X Offline
    X Offline
    Xavier Shay
    wrote on last edited by
    #1

    I have a string formatted as such: "The last word is \ggreen" I want to place this text in a Rich Edit Control, replacing '\g' with the change of color to green. At the moment I'm thinking of making a loop to cycle through the string placing each letter in one at a time and changing the default color when \g is encountered. This seems grossly inefficient, is there a better way to do it (Escape codes ala DOS??) - X

    L 1 Reply Last reply
    0
    • X Xavier Shay

      I have a string formatted as such: "The last word is \ggreen" I want to place this text in a Rich Edit Control, replacing '\g' with the change of color to green. At the moment I'm thinking of making a loop to cycle through the string placing each letter in one at a time and changing the default color when \g is encountered. This seems grossly inefficient, is there a better way to do it (Escape codes ala DOS??) - X

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

      I'm not sure how much better a solution this would be but here goes, you could try searching for the '\g' and place everything previous to it into the control, then change the colour and then place the rest of the text. I think this would be more efficient because it would then only require the rich edit control to call your EditStreamCallback function twice in the case of your sample string (as opposed to the 20 odd calls it that would be required if you did it character by character). Just a thought... Ben Burnett "It's all absolutely devastatingly true -- except the bits that are lies" - Douglas Adams

      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