Thread: Constantly updated editable colored text

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    245

    Constantly updated editable colored text

    I need to show about 35 lines (of approx 80 chars in width each) of colored text, meaning different colors along the line. This text will be updated when the user uses the Pageup/pagedown keys.

    First thing I thought about was a Richedit. I can't put all the text in the rich edit at once, as a change on the first page will change the text on the second page (for example). So therefore, I need to catch all the pageup/pagedown keys and update the screen myself. Rather than clearing the richedit each time and readding all the lines, I have 35 lines permanently in the listview and simply change the lines as the data in them changes.

    Now although this works, it creates a large amount of flickering as the richedit control itself seems to completely blank out the control and then redraw all the text each time I update.

    Is there anyway around this? I don't mind handling the redraw myself, but it doesn't seem like this is possible. I'm using C++ Builder 6.

    What I've tried so far is that before and after all work is done in the richedit, use the LockWindowUpdate function, send the SETREDRAW message to the control, and even the VCL's built in "Richedit1->Lines->Begin/EndUpdate" function. However, none of these seem to work - they all have the same flicker.

    It seems the only way around this problem would be to draw onto a bitmap and place this on top of the form directly (kind of Doublebuffered display). However, the Richedit does not support Doublebuffered mode, and I don't want to rewrite the control from scratch.

    Any ideas?

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    I don't know for sure because I don't use Builder, but Windows "helpfully" send a WM_ERASEBKGND message to an area that shall be repainted or resized. What it basically does is causes the background of the area to be painted to be set to the default Windows background colour.

    Try trapping this message and return TRUE in your windows processing loop.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    245
    No good. It seems that because of the way I'm using the control, a richedit is not really practical enough for this application.

    I've now changed the richedit into a Listbox, and enabled custom drawing, so I can completely control all functionality. I get all the usual key messages to this control also, so turning it into a text editor will not be that difficult.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 06:21 PM
  2. Moving to the next structure array
    By mattz in forum C Programming
    Replies: 2
    Last Post: 11-30-2001, 03:43 PM
  3. Structure problem
    By mattz in forum C Programming
    Replies: 10
    Last Post: 11-30-2001, 01:19 PM
  4. Colored Text
    By Yoshi in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 11-28-2001, 09:46 AM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM