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

Write Your Customized Editor for Your Own Programming Language

, 13 Jun 2004
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Taha Amin
Team Leader http://www.linkdev.com/
Egypt Egypt
B/OSS.

Comments and Discussions

 
GeneralHi ! Pinmemberjaorsoftware4-Feb-11 3:14 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 14 Jun 2004
Article Copyright 2004 by Taha Amin
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid