?
Solved

Syntax Highlighting in an edit box

Posted on 2003-10-22
4
Medium Priority
?
314 Views
Last Modified: 2013-11-20
I have an edit box which is displaying piped output from an external process.  I would like to get some syntax highlighting into the text.  I have been messing around with this module http://www.codeguru.com/richedit/SyntaxColorizer.html.  It works fine with my test case executable, but when I use it with my actual executable it does not work(it's a simple swap of executables or recoding on the MFC app side of things).  I was wondering if anyone knows what I need to do or if there are other alternatives to change colors or certain words in an edit box.

Note: the output is not source code, I just need to highlight error messages and certain values displayed.

thanks in advance
0
Comment
Question by:Logick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 9604800
An edit box only has one font and one colour at any one time.  Use a RichEdit control for multiple font/colour display.
0
 
LVL 3

Expert Comment

by:komar
ID: 9607074
Check the article at link: http://www.codeproject.com/wtl/wtleditor.asp

The article introduces a library called CodeMax that can be used for syntax highlighting. There you can find some demo project and documentation for the library.

- Khalid Omar
0
 

Author Comment

by:Logick
ID: 9608425
To AndyAinscow:
I am aware that I need to use RichEdit which is what I am using, but still I have not found a way to highlight certain words in my program.

To komar:
Thanks for the link it seems useful but codemax seems a bit of overkill for what I need it for, anything simpler?
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 9608522
Hi Logick, an excerpt from your question:
I have an edit box


This is a snippet from a RichEdit view based app I did some time ago.  It could be of use
      CRichEditCtrl& ctlREdt = GetRichEditCtrl();

      CHARFORMAT cf, cfOld;
      cf.cbSize = sizeof(CHARFORMAT);
      cfOld.cbSize = sizeof(CHARFORMAT);

      ctlREdt.GetSelectionCharFormat(cfOld);

      cf.dwMask = CFM_COLOR | CFM_SIZE | CFM_FACE;
      cf.crTextColor = RGB(0, 0, 0);
      cf.yHeight = 10 * 20;      //Heights are in 1/20 'th of a point
      _tcscpy(cf.szFaceName, _T("Arial"));

      ctlREdt.SetSelectionCharFormat(cf);
      ctlREdt.ReplaceSel(szMessage);

      ctlREdt.SetSelectionCharFormat(cfOld);



and another snippet
      CRichEditCtrl& ctlREdt = GetRichEditCtrl();

      //Force it to append to the end of the edit control if the user has selected anything with the mouse
      int iLastLine = ctlREdt.GetLineCount() - 1;
      if(iLastLine > 0)
      {
            long lLastChar = ctlREdt.LineIndex(iLastLine) + ctlREdt.LineLength(iLastLine);
            ctlREdt.SetSel(lLastChar, lLastChar);
      }

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question