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.
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();
Global.UnregisterAllLanguages();
CodeMax.Language lang=new CodeMax.LanguageClass();
lang.CaseSensitive=false;
lang.Keywords="\n";
lang.TerminatorChar=@";";
lang.Style=CodeMax.cmLangStyle.cmLangStyleProcedural;
Global.RegisterLanguage("TahaSQL",lang);
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.