Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Write Your Customized Editor for Your Own Programming Language

0.00/5 (No votes)
13 Jun 2004 1  
An article on a customized editor for your own programming language
Sample Image -CodeMax Control

Introduction

I searched for a control that would allow me to make a color editor for my custom keywords. I developed an RDBMS program called Store (I will post it later) and I allowed a user to enter a SQL query (look at the picture below) at run time so I needed a control to color SQL keywords. However, I didn't find something to help me in C# MSDN, so I search the Web and I found it 'CodeMax.ocx' control. It's a fantastic control that allows you to specify the keywords you want and it colors it for you.

Sample Image - from Store

Using the Code

You will find CodeMax v2.0 in two forms (codemax20.ocx for Visual Basic, codemax20.dll for Visual C++). Get it and copy to 'C:\windows\system32\' and then type this command run dialog 'regsvr32 codemax20.ocx'. You will get a message telling you that com has been registered.

Choose a new Windows control project . Add the CodeMax control to the tools box, then pass it on your control and set the dock property to fill in the class constructor. Write the following code:

CodeMax.Globals Global=<CODE>new CodeMax.GlobalsClass();
//unregister all languages specified with the control(like c++).
Global.UnregisterAllLanguages();
//define a new language
CodeMax.Language lang=new CodeMax.LanguageClass();
//specify if your language character is case sensitive
lang.CaseSensitive=false;
//enter all keywords separated by '\n'.
lang.Keywords="\n";//write your key words here separated by \n
                        
lang.TerminatorChar=@";";//specify line terminator character
            
lang.Style=CodeMax.cmLangStyle.cmLangStyleProcedural;
//choose a name for your language
Global.RegisterLanguage("TahaSQL",lang);
//your language is now ready to use so 
//set properties to your control
                        
this.axCodeMax1.Language="TahaSQL";
this.axCodeMax1.LineNumbering=true;
this.axCodeMax1.LineNumberStart=0;
this.axCodeMax1.ColorSyntax=true;
this.axCodeMax1.LineNumberStyle=CodeMax.cmLineNumStyle.cmDecimal;

Points of Interest

You also need to write some methods to get or set properties to the control. After that, you will get a control which you can use in any .NET application without any problem.

Hints

Please read the documentation. You will find more properties like a property to get text from the control, get a line number, highlight specified line, and more.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here