Click here to Skip to main content
Click here to Skip to main content

Brainchild, A syntax coloring edit control

By , 16 Jun 2005
 
Prize winner in Competition "MFC/C++ Oct 2002"

Notes

The search and replace dialogs in version 2.4 and higher of the brainchild control are non-modal. This will require you to call the newly introduced API IsNonModalDialogMessage() in the main message loop of your application. Old code using the control should be updated. Failure to do so will result in shortcut keys and tab/shift tab navigation not working.

The compiled binaries archive contains the compiled versions of brainchild.dll, bcc.cpl, BCDemo.exe and brainchild.ocx. Please note that the setup as explained below is still needed to make it all work.

Introduction

Brain child is an editor control which supports all the bells like syntax coloring, multi-level undo/redo etc. The editor control comes in three parts.

  1. Brainchild.dll which is the editor control. It is the core component which is written in C.
  2. BCC.cpl which is the configuration control panel applet. This is written in C++ and depends on my ClassLib library.
  3. Brainchild.ocx which is an ActiveX wrapper for the control. It is written in C++ using MFC. This OCX makes it possible to used the brainchild control in VB or .NET applications.

In addition, I have included a simple MDI editor demonstration program called BCDemo which is written in C++ and also depends on my ClassLib library.

Features

Brainchild supports most modern editor capabilities including:

  • Syntax-coloring, fully configurable. Syntax coloring is supported both on screen and on printer output.
  • Multi-level undo/redo. Maximum number of hops configurable.
  • Bookmarks.
  • Line numbers.
  • Fully configurable keyboard mappings.
  • OLE drag and drop support.
  • Automatic/smart indentation.
  • Automatic case fixing.

How to get started

I have not included an installer package. This means that you must follow several steps to get the editor up and running.

  1. Download the source code (DLL, CPL, OCX (optional), BCDemo) or the compiled binaries. If you decide to use the compiled binaries, you still need to download the DLL source code. It contains necessary setup files which you will need to get things running. If you use the compiled binaries only, you can go to step 7.
  2. Download, setup and compile the ClassLib C++ library.
  3. Compile the brainchild DLL.
  4. Compile the brainchild CPL.
  5. Compile and register the brainchild OCX (optional).
  6. Compile the BCDemo demonstration program.
  7. Create a directory on your hard disk where you can put the brainchild configuration files.
  8. Copy the directory Defaults, which you can find in the DLL source zip, including all its contents to the created directory.
  9. Open RegEdit.
  10. Add the key HKEY_LOCAL_MACHINE\Software\BCDLL\CurrentVersion. (Be careful using the registry editor!)
  11. In the key, add the string value Settings and set its value to the directory you created for the brainchild configuration files.

To get the demonstration program up and running, copy the branchild.dll, brainchild.ocx and bcc.cpl files to the directory containing the BCDemo executable and you should be able to run the demonstration program. Do not forget to register the OCX if you want to use it. You can use RegSvr32 to register the OCX. Once you get it up and running, you might also want to download the HTMLHelp docs. It will explain, how to use brainchild in your own programs and how to use the configuration tool.

What's New

Version 2.4

  • Enhanced the Find and Replace dialogs.
  • Much better printer support.
  • Added support for background colors.
  • Added bracket and line highlighting.
  • Added an ActiveX wrapper so that brainchild can be used in VB and .NET apps.
  • Added support for hyperlinks.
  • Fixed some bugs.

Version 2.3

  • Fixed a couple of nasty bugs.
  • Support for loading and saving Unicode files (limited support for loading and saving only).
  • Added case-fixing. When turned on, this will automagically fix keyword casing. Suggested by Zodiakon.

Version 2.2

This version includes a WTL wrapper and a small WTL demonstration program (VS6 workspace only) by Ernest Laurentin which you can download using the links above. For this release, only the Brainchild_dll.zip and Brainchild_help.zip were updated. The Brainchild_wtl.zip was added. The BCC.cpl and BCDemo source were not updated so version 2.1 users do not have to download these. Also note that the VS7 solution is a Visual Studio .NET 2002 solution. I presume you can load this into Visual Studio .NET 2003 without any problems.

  • The control now loads if the registry keys are not set. If they are, the directory configured must have the "Defaults" directory including contents copied into it.
  • Added the LoadParserFromFile() and LoadParserFromMemory() APIs including corresponding messages. These will allow you to add parser files at run time.
  • Fixed a nasty bug which could crash brainchild after receiving a WM_DESTROY. This has been fixed.

Version 2.1

  • Line numbers. The control now supports the possibility to show line numbers.
  • WM_PRINTCLIENT support.
  • WM_MOUSEWHEEL support.
  • Some bug fixes. Mostly small rendering bugs when run under Windows XP.

Version 2.0

  • Initial release on the CodeProject.

Thanks

The control has been re-written several times over the last years. To get it to where it is now, I have based some of the code on the work of Andrei Stcherbatchenko's CrystalEdit component. The code which was based on his work mostly covers the undo/redo and text buffer stuff.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jan van den Baard
Software Developer (Senior)
Netherlands Netherlands
Member
I have been programming for a hobby since 1985. I have started programming on the C= 64. After that I migrated to the C= Amiga which I traded in for a PC back in 1997 I believe. Back in 2000 I decided to lose a hobby and start developing software for a living.
 
Currently I am working mainly in developing software for building security and access control systems.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 3memberbuyong26 Sep '11 - 15:01 
can not compile the source code correctly.
with the following error:
can not find
#include
GeneralBrainchild and Borland C++memberselinek13 Mar '10 - 8:57 
Hi,
 
my preferential IDE for C++ is CBuilder 6 and BDS 2005,
so I'd like to compile this phenomenal component in this compiler.
I'm trying to compile, but I have the impression that this source is intended for VC++...
how I make it?
 
regards
 
Zenek
QuestionUnicode Support??membereqbalsajadi4 Aug '09 - 19:39 
How to enable accepting unicode such as Arabic characters? do you have an idea?
AnswerRe: Unicode Support??memberJan van den Baard6 Aug '09 - 3:32 
I am afraid that support for unicode in Brainchild is extremely basic. Input of unicode characters is not supported at all.
 
We are the all singing, all dancing crap of the world. - Tyler Durden

GeneralMany thanksmemberDavidHarper21 Jun '09 - 11:28 
For a long time I've looked for a program that would allow me to print C code with syntax color highlighting. The best that I had found was emacs (my normal editor) which used Ghostscript and was able to print basically what I saw on the screen. It worked, but was horribly slow - a six page print could take around a half hour (it produced nearly 100 MB per page). This afternoon I decided to see if maybe something else was available and came across your program. Didn't take that long to set up using the instructions in the article, and I am now able to print at roughly the same speeds as I would from editors like notepad.
 
Thank you for taking the time to create this program and share it with the world.
 
Regards,
Dave Harper
GeneralRe: Many thanksmemberJan van den Baard21 Jun '09 - 20:51 
DavidHarper wrote:
Thank you for taking the time to create this program and share it with the world.

 
You are welcome. I'm glad you found it usefull. Never though it would be used for it's printing abilities Smile | :)
 
We are the all singing, all dancing crap of the world. - Tyler Durden

QuestionHow to call the configuration setting in Visual Studio (C#) project?memberkarenphg7 Apr '09 - 0:08 
Hi,
Can anyone tell me how to call the config setting in C# project?
Thanks!
AnswerRe: How to call the configuration setting in Visual Studio (C#) project?memberJan van den Baard7 Apr '09 - 1:39 
I have never tried to call the CPL from managed myself but this article may be of help.
 
http://www.codeproject.com/KB/cs/appletengine.aspx
GeneralBackground Delimeter ColormemberTeeJayMule1016 Mar '09 - 17:07 
Hello Again Jan & all,
 
Can you please tell me if I can programmatically change the Delimeter Background Color for the selected line ONLY. I wish to do this so that the delimeters on the currently selected line do not standout but are the same color as the selected line's background color.
 
Regards
 
Mule
GeneralRe: Background Delimeter ColormemberJan van den Baard8 Mar '09 - 20:55 
TeeJayMule101 wrote:
Can you please tell me if I can programmatically change the Delimeter Background Color for the selected line ONLY. I wish to do this so that the delimeters on the currently selected line do not standout but are the same color as the selected line's background color.

 
There is no way you can influence the colors for the selected line only. To get this to work like you want it to you will need to make some changes to the Brainchild source code. Something like a flag that says not to use text background colors on the current line when the current line marker is shown...
 
We are the all singing, all dancing crap of the world. - Tyler Durden

GeneralCannot Register OCX FilememberTeeJayMule10120 Jan '09 - 2:12 
Hi,
 
I am using Windows XP SP3 and I have tried to install this control in Visual Studio 2008 but the control fails to self-register. I have tried to manually register it with REGSVR32 but it produces an error which is caught by JIT debugger.
 
Can you please tell me what could be causing this problem?
 
I am using the .ocx, .dll & .cpl file from the Brainchild compiled binaries file. I have recently reinstalled but I have not had any problems installing this control in XP or VS2008 in the past.
 
Thanks and regards
GeneralRe: Cannot Register OCX FilememberJan van den Baard21 Jan '09 - 3:54 
Hi,
 
I have just checked on my virtual machine running XP + SP3 with the binaries downloaded from CodeProject and the binaries from my latest build and in both cases the ocx registers OK.
 
I can also add it to my toolbox in VS 2005. I am not at my personal machine now which has VS 2008 installed so I have not tested it on VS 2008 but I can't see why that would be a problem.
 
Just to make sure:
 
1) Are your settings (.bcp) files OK?
2) Are your registration settings for Brainchild OK? (LOCAL_MACHINE\Software\BCDLL\CurrentVersion\Settings)
3) Are the .cpl, .dll & .ocx located in the same folder?
4) Do you have admin rights to perform the registration?
 
If so what is the error you get when trying to register the component?
 
Bye,
Jan
 
We are the all singing, all dancing crap of the world. - Tyler Durden

QuestionConfiguration Editor TitlememberTeeJayMule1017 Oct '08 - 11:31 
Hi,
 
First of all, I wanted to say thank you for this wonderful control. I am currently using it in a C# project I am working one, completely trouble free Smile | :) It's a very easy to use, attractive and comprehensive Editor control. It has taken many many months if not years off my project. So thank you again Smile | :)
 
I have really only one small concern. I would like very much to change the name of the configuration editor, from what it is ("Brainchild configuration editor.") to something a little more generic (ie "Editor Options" or "Configuration Options", something in title case and without the dot on the end).
 
Unfortunately I am new c# and very new to c++, otherwise I would compile a new version of the Configuration Applet. This being said, it there anyway you could build and post on this site another version of the BCC.cpl binary with the title changed to one of the above? Alternatively, could you step me through how to compile a new version myself. I have Visual C++ Express 2005.
 
Thanks & Kindest Regards
AnswerRe: Configuration Editor TitlememberJan van den Baard8 Oct '08 - 20:34 
Hello TeeJayMule101,
 
It is probably a to big of a job to try and compile a new version of the cpl with VC express. On the other hand it is also difficult for me to provide you with a version with the requested changes.
 
If you really want only to change the title of the configurator you are probably best of to "patch" the BCC.cpl file. Simply open it in VC++ in the binary editor and look up the title text. As long as you do not make the title longer than it already is you should be able to change it there (Do not forget to terminate the new title with a 0 byte).
 
Bye,
Jan
 
We are the all singing, all dancing crap of the world. - Tyler Durden

GeneralRe: Configuration Editor TitlememberTeeJayMule1019 Oct '08 - 2:31 
Hi Jan,
 
Thank you very much for your reply. I have been able to change the title of the Editor to what I wanted, thanks to your help.
 
Kindest Regards
 
TeeJay Smile | :)
GeneralText wrappingmemberShakeeb19 Mar '08 - 6:03 
Hello all,
 
Is there any way to wrap the text to fit the container area and avoid horizontal scroll bars?
Generallicense?? reditributingmemberbrianhood7 Feb '08 - 15:21 
this is a great setup, you or one of the best programmers I seen.
I'm a hobby programmer that ponds out code, cutting and pasting because I'm not a good typist and I studied Lots of programming languages, started on trs80 and Qbasis, stop until windows 95 began wit c and it seem strange the tried Liberty basic, then relies it great for quick utilities but to slow for large programs,
went back to tried c++ classes confuse me because the book I used use student,teacher and class room stuff to explain,got on the internet started Jscript love it, tried Pearl don't like it, began PHP like it, and sql for the internet.anyway I mite not write the best programs but I can read them fix them and can tell good ones from bad.
yours or great, comment good, good procedures,compact with all the bell and whistles.
 
I'd like to set your code up as a platform on my computer and add a project manager to it.
 
I sell programs on ebay and would get $5 for it.
 
I do not what to go behind your back since you spent a lot of time and effort. I will include your copyright in the install,help, and about box.
 
please give me a good copyright acknowledgement to use
GeneralRe: license?? reditributingmemberJan van den Baard9 Feb '08 - 7:46 
You can use the code in any way you see fit. Commercial or otherwise. Complete or only parts of it. It is free for anyone to use.
 
-Jan
 
We are the all singing, all dancing crap of the world. - Tyler Durden

QuestionNew version?member[Jongware]31 May '07 - 13:03 
When can we expect a new version, with the Defaults directory bug (slash Create Registry key) fixed?
Elsethread you mention a possible version problem between the DLL and the compiled binary. However, I just downloaded both minutes ago, entered the registry key manually, and got that dreaded error message.
... That said -- great job! My free tip of the day: If you ever feel like checking the world of Unicode, you should read James Brown's catch22[^] pages.
 
[JW]
AnswerRe: New version?memberJan van den Baard1 Jun '07 - 3:34 
I'm afraid it can be a long wait since I am no longer actively developing Brainchild. Even though I have developed the control beyond what you can download here I no longer have the time or energy necessary to develop the control any further.
 
Regards,
Jan
 
We are the all singing, all dancing crap of the world. - Tyler Durden

Generalcan't compile the demo on Visual Studio 2005memberuniquekaiser7 Feb '07 - 8:41 
Hi, i'm new in OOP and i'm learning how to program on visual studio 2005.
 
When i tried to compile the demo i got:
Error 5 fatal error C1083: Cannot open include file: 'classes/all.h': No such file or directory c:\documents and settings\optimus primum\escritorio\brainchild\bcdemo\bcdemo\bcdemo.h 6
 

How can i solve this?
 
how can i use brainchild on a IDE that i want to develop in visual Studio .NET?
GeneralRe: can't compile the demo on Visual Studio 2005memberbrianhood7 Feb '08 - 14:29 
I created a file classes in the visual studios VC include directory
the project default includ dirrectory what ever that is and then extract the classli.zip to it.
 
I really extract it to my desttop in a new folder but when I got the message and seen
the <> was a clue it shound be a compilers include path and copied it to c:\program files\microsoft visual studio\vc7\include directory.
 
this will solve many of the compile problems
QuestionRegistration ErrormemberAnt Htoo Naing4 Dec '06 - 5:29 
I download source code of DLL and OCX. When I compile OCX using the DLL I have compiled on my machine, I got "Performing Registration Error" during compilation. If I use original DLL and LIB file to compile OCX, it is OK. When I try to register compiled OCX from command line, I got LoadLibrary("BrainChild.ocx") failed - Invalid access to memory location error. Anybody know what is happening? Confused | :confused:
I am using Visual Studio 2005 to compile these two project.
Thanks,
Ant.
GeneralBrainchild control panel multi-user BUG! [modified]memberjwh42419 Nov '06 - 5:13 
After playing with the registry for about an hour. I've noticed that not all Windows Version allow read access from the "HKEY_LOCAL_MACHINE" key. Especially some Windows XP HOME OEM versons. You have to go into safe mode (or administrator mode) to read it. Users with laptops like DELL, Compaq or HP will have a problems setting up BrainChild Control Panel with the registry.
 
So, BrainChild Control Panel will only work if you are the administrator.
GeneralRe: Brainchild control panel multi-user BUG! FIXED!memberjwh42419 Nov '06 - 6:35 
I've made a small change to the BCC source. In the main.cpp, I just changed HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER key. So, that it will work for multiple users and the administrator.
 
Open the registry to HKEY_LOCAL_MACHINE\Software\BCDLL\CurrentVersion. Add the string key "Settings". Then change that value to the path of the configuration files (*.bcp, from dll source).
 
Then, do the same for HKEY_CURRENT_USER\Software\BCDLL\CurrentVersion. Add the string key "Settings". Then change that value to the path of the configuration files (*.bcp, from dll source).
 
HKEY_LOCAL_MACHINE\Software\BCDLL\CurrentVersion and HKEY_CURRENT_USER\Software\BCDLL\CurrentVersion keys must equal and the path must be correct.
 
This should help a lot of people.
 
I love this control, thanks so much! Big Grin | :-D
 
James harris

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 17 Jun 2005
Article Copyright 2002 by Jan van den Baard
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid