| featured products | ||
![]() |
![]() |
![]() |
The Exontrol's eXHelper tool helps you to find easy and
quickly the answers and the source code for your questions regarding the usage of our UI components.
The eXHelper is free to use for anyone that wants to start working with any of our UI component.
Click the programming language you use for general questions:
Click the programming language you use for how-to questions:
Listed below are the questions that we are asked quite often. Before you write us, be sure to check here.
How can I get ride of the images panel that shows at design time?
How can I delete an icon from the images list window, shown at design time?
I am wondering how can I add print and print preview capabilities to my editor?
I am trying to highlight a line but it doesn't seem to be working?
How do I implement menu functions such as Cut, Copy, Find, Replace, Paste, Undo or Redo?
Is there any way to change the background color for the cursor line?
Is it possible to have only one column for line numbers and bookmarks?
Is it possible to have the line numbers width be set automatically?
Is there any event that notifies my application that the position of the cursor is changing?
How can I notify my application that the user bookmarks a line?
Is there any way to add new items to the control's context menu?
Would it be possible to let the user change the way a bookmark is displayed?
It it possible to have a sort of multiline coloring for comments available?
Is there any option to ignore the \" sequences inside strings ( back slash character )?
Is there any event that occurs if the user opens the control's context window ( CTRL + SPACE )?
Marking is an interesting feature. It does not work for multiline expressions though. Am I doing something wrong?
Can I change the cursor that control displays when the mouse pointer hovers the line number bar?
| Just press CTRL+F ( or select Edit\Find menu item ) and you have a dialog that will help you to locate the string that are you looking for. |
| The control's release notes can be found on our web site, looking for the Release Notes column in the control's main page. Click here for direct link. |
|
The control provides a collection called Context that helps you to add new items to context drop down portion. You can invoke the drop down context window, by pressing CTRL+SPACE. If you want to provide icons for items in the drop down portion, you have to use the Images method. The following sample adds few items to drop down portion: With .Context("")
.Add "<fgcolor=FF0000>class</fgcolor>", , 1
.Add "<fgcolor=0000FF><b>public</fgcolor>", , 2
.Add "<fgcolor=0000FF><b>protected</fgcolor>"
.Add "<fgcolor=0000FF><b>private</fgcolor>", , 3
End With
|
|
The AddKeyword method adds new entries to control's keywords collection. When using AddKeyword method you have to use built-in HTML tags to highlight your keyword. For instance, if you have a keyword, let's say, 'public', and you want to have it blue, you have to use the code like follows: .AddKeyword "<fgcolor=000080>public</fgcolor>" As you can see the 'public' keyword is delimited by <fgcolor> and </fgcolor> built-in HTML tags. The <fgcolor> and </fgcolor> built-in HTML tags will be used by the control when 'public' keyword will be reached in the control's text. If you have a keyword, let's say 'protected', and you want to have it bolded and red, you have to use the code like follows: .AddKeyword "<b><fgcolor=FF0000>protected</fgcolor></b>" The <b>, <fgcolor> built-in HTML tags will be used by the control when 'protected' keyword is found in the control's text. |
|
The AddExpression method adds new entries to control's expressions collection. An expression is composed by beginning part, middle part and ending part. The beginning part defines the start of the expression. The ending part defines the end of the expression. The middle part defines the built-in HTML tags that will be applied to expression excluding the beginning and ending parts. The beginning and ending parts may contain also built-in HTML tags. For instance let's say that we want to have green all expressions that start with '// characters', then we should use code like follows: .AddExpression "<fgcolor=008000>//</fgcolor>", "", "" In this case, the <fgcolor> built-in HTML tag will be used for the entire expression. For instance, the line like 'class A //Defines the class A ', will look like 'class A //Defines the class A '. The <fgcolor> built-in HTML format is applied to the entire expression because the middle part is missing ( empty ). If you have an expression like follows: .AddExpression "<fgcolor=008000>//</fgcolor>", "<b> </b>", "" The line will look like follows: 'class A //Defines the class A '. As you can see the beginning part is green, and the middle part gets bolded but no green. If you want to have the middle part also been green, you have to append a new <fgcolor> HTML format to the middle part like follows: .AddExpression "<fgcolor=008000>//</fgcolor>", "<fgcolor=008000><b> </b></fgcolor>", "" In this case the line looks like: 'class A //Defines the class A ' For instance if you need to highlight a text delimited by " ( quote ) characters, you need to have something like:
The beginning and ending parts contains two "" characters because that means only one when they are included in other string expression. So, string like: "blabla" will look like: "blabla". As you can see that the red color is used for all parts. If you need any of the expression parts you need to add/remove built in HTML tags when adding the expression. Let's say that we want to have a red string, but everything that's in the " characters we need it underlined, so the expression should be like:
So, a string like "blabla" will look like "blabla". As you can see only blabla is underlined. |
|
The control provides an image list window, that's displayed at design time. Use the
ShowImageList property to hide the image list window, at design time. At design time, the user can add new icons to the control's Images collection, by dragging icon files, exe files, etc, to the images list window. At runtime, the user can use the
Images and
ReplaceIcon method to change the Images collection. The Images collection is 1 based. Edit1.Images ImageList1.hImageList |
|
The control provides a property ShowImageList that shows or hides that images list. By default, the property is True, to let new customers know that they can drag images without using an ImageList control. If you are going to add icons at runtime the control provides Images and ReplaceIcon methods. The Images method takes the handle to an ImageList control. The ReplaceIcon method works like follows:
|
| You can delete an icon from the images list window in design mode by selecting the icon and pressing the BackSpace key. You can delete the icon using the Delete key but some containers delete the object when Delete key is used. |
| The control provides the LineNumberWidth property that specifies the width of the line number bar. By default, the width of the line number bar is 0, and no line number bar is displayed. Use the LineNumberWidth = 0 to hide the line number bar. The LineNumberWidth is available at design time also. |
|
The InsertText method inserts text to control's content. For instance, the following statement adds a new line: .InsertText "new line" |
|
The TextLine property gets the line based on its index. The Text property gets the all lines of the control's text. The following statement enumerates the lines in the control:
|
|
The Exontrol ExPrint component ( exprint.dll ) provides Print and Print Preview capabilities for the exEdit component. Once that you can have the exPrint component in your Components list, insert a new instance of "ExPrint 1.0 Control Library" to your form and add the following code:
The exEdit control supports the following options when using the Options property of the exPrint component:
The following VB sample opens the Print Preview frame: With Print1
.Options = "break: |#_"
Set .PrintExt = Edit1.Object
.Preview
End With
The following C++ sample opens the Print Preview frame: m_print.SetOptions(COleVariant("break: |#_"));
m_print.SetPrintExt( m_edit.GetControlUnknown() );
m_print.Preview();
The following VB.NET sample opens the Print Preview frame: With AxPrint1
.Options = "break: |#_"
.PrintExt = AxEdit1.GetOcx()
.Preview()
End With
The following C# sample opens the Print Preview frame: axPrint1.Options = "break: |#_"; axPrint1.PrintExt = axEdit1.GetOcx(); axPrint1.Preview(); The following VFP sample opens the Print Preview frame: with thisform.Print1.Object
.Options = "break: |#_"
.PrintExt = thisform.Edit1.Object
.Preview()
endwith
If you are using C++, with MFC support, the GetControlUnknown property of CWnd class gets the object hosted by a window, and it should be passed to SetPrintExt method:
The Exontrol Print Preview mainframe looks like follows:
|
|
The Picture and PictureDisplay properties help add and arrange a picture to the control's background. The following sample puts a picture on the bottom-right corner of the control:
If you are a VC developer, you can use the LoadPicture function described here. |
| The properties like SelStart and SelLenght should be used to highlight your text. The control hides the selection if the HideSelection property is True. Change the HideSelection property to false, and you will be able to see the changes. |
|
Use the Text property to clear the control's content. The following sample clears the text:
|
|
You can use the SelectLine property or you can use the SelLenght property. The following snippet of code shows how to highlight the current line ( the CaretLine property retrieves the position of the current line. The current line always contains the caret ):
If you need to highlight a specific line you have to call:
|
|
The AddKeyword method allows specifying the description of the keyword's tooltip and its title. The tooltip appears when the user moves the cursor over the keyword. The following sample assigns a tooltip to "public" keyword: |
| Starting with version 1.0.0.9 the exEdit components supports multi levels Undo/Redo support. The AllowUndoRedo property specifies whether the control's Undo/Redo support is enabled or disabled. |
| The object's identifier is "Exontrol.Edit". The object's CLSID is "{39136531-DD0F-4281-B445-E36FC2CDDBC5}". |
|
You can invoke any of the following commands: Delete, Copy, Cut, Find, FindNext, FindPrev, Paste, Select All, Undo and Redo. Each command has an unique identifier like follows: #define ID_EDIT_REPLACE 0xE129 #define ID_EDIT_DELETE 0xE120 #define ID_EDIT_COPY 0xE122 #define ID_EDIT_CUT 0xE123 #define ID_EDIT_FIND 0xE124 #define ID_EDIT_PASTE 0xE125 #define ID_EDIT_SELECT_ALL 0xE12A #define ID_EDIT_UNDO 0xE12B #define ID_EDIT_REDO 0xE12C #define ID_EDIT_FINDNEXT 0xE12D #define ID_EDIT_FINDPREV 0xE12E The sample requires the definition for SendMessage API function. For instance, the following VB sample shows how to call Undo command when user clicks a button. The wParam parameter of SendMessage API function needs to be Command's Identifier * 65536. The following C++ sample shows how to call Redo command when user clicks a button:
The CanUndo property determines whether the last edit operation can be undone. The CanRedo property determines if the redo queue contains any actions. |
| The HideSelection property of the control specifies whether the selection in a edit control is hidden when the control loses the focus. By default, the HideSelection property is True. |
| The control provides Find and Replace support. The AllowFind property specifies whether the control can search for a string using the built-in Find dialog. By default, the AllowFind property is True. The control displays the Find dialog if the user presses CTRL+F key. If you need to change the key combination that invokes the Find dialog, you have to handle the KeyDown event and to call Find command like explained in " How do I implement menu functions such as Cut, Copy, Find, Paste, Undo or Redo?". The F3 key finds the next occurrence of the previous search text. The Shift + F3 finds the previous occurrence of the search text. The control's Find method finds and highlights a string. |
|
| The control provides the BackColorCaretLine property that retrieves or sets the background color used to display the cursor line. The property BackColorCaretLine has effect only if it is different than 0. |
|
The control provides a WYSWYG Layout editor that helps you to call any of control properties or methods at design time. Select 'Properties' item from control's context menu, when you are at design mode. Select 'Template' page from control's Properties dialog. The 'Template' page can be used to initialize the control, by calling its properties or methods. For instance the following sample adds few keywords to the edit control:
The following samples adds items to the control's context list window:
|
|
You can use the ability of the control to load and execute a list of instructions like explained in How can I set the coloring scheme at design time?. For instance, the following sample changes the control's background and foreground colors by using the Template property.
Let's suppose that we have a file with the following content: Lines are separated by the vbCrLf ( \n\r ) characters. You can assign the keywords and expressions to the control by loading the file to a string variable, and by passing the string to the Template property. |
| The control scrolls its content when the user selects lines at the top or the bottom of the control. All that you need to do is to wait 100 ms until auto scroll is enabled. |
|
The FormatNumbers property specifies the HTML format for numbers. By default, the FormatNumbers property is "<fgcolor=0000FF> </fgcolor>". The following sample bolds and colorizes the numbers:
The ' ' blank character inside the expression is required. If it is missing the property has no effect. |
|
The InsertText method inserts text at specified position. The following sample adds an empty line to the top of the control:
|
|
The CaseSensitive parameter of AddKeyword method defines the type of the keyword. By default, the keywords are case sensitive. The following sample adds a case sensitive keyword ( the exCaseSensitiveKeyword is not required, because the AddKeyword adds by default a case sensitive keyword ) : With Edit1
.AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", , , exCaseSensitiveKeyword
End With
In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highligted as 'class', 'ClaSs', 'clasS', and so on. The exCaseSensitiveKeyword constant is 0 The following sample adds a non case sensitive keyword: With Edit1
.AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", , , exNonCaseSensitiveKeyword
End With
In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highligted as 'class', 'ClaSs', 'clasS', and so on. The exNonCaseSensitiveKeyword constant is 1 The following sample adds a non case sensitive keyword, but any occurrence of the keyword in the text will be displayed as it is defined: With Edit1
.AddKeyword "<fgcolor=0000FF><b>class</b></fgcolor>", , , exReplaceKeyword
End With
In this case, if you are tying 'class', 'ClaSs', 'clasS' and so on, it will be highlighted as 'class', 'class', 'class', and so on. The exReplaceKeyword constant is 2 |
|
The AddWild method adds an expression that may contain wild characters like '*' or '?'. For instance the following sample underlines all 'a' in the text:
Note that if you are adding a keyword like:
only 'a' characters that are not in words will be underlined. The wild characters expression may contain '*' that means any string of characters and '?' that means a single character. For instance the following sample bolds all expressions that starts with '<' and ends with the '>' and it has at least once character inside.
Note that if you are adding an expression that starts with '<' and ends with '>' the expression will be highlighted even there is no character between them:
If you want to highlight only the part between '<' and '>' then you should use a sample like follows:
|
|
The BookmarkWidth property specifies the size of the bookmarks border. If the BookmarkWidth property is 0, no bookmarks border is displayed. If the BookmarkWidth property is grater than 0 the control sets the width of the bookmarks border to specified size. If the BookmarkWidth property is less than 0, and the line numbers border is displayed, it displays the line bookmarks too. The following sample allows you to put the line numbers and bookmarks on the same column:
|
|
The LineNumberWidth property specifies the width of the line numbers border. If the LineNumberWidth property is 0 the control displays no line numbers border. If the LineNumberWidth property is less than 0 the control sets the width of the line numbers border automatically. If the LineNumberWidth property is positive the control sets the width of the line numbers border to the specified size. The following sample displays the line bookmarks and line numbers on the same column, and the column is automatically sized:
|
|
The Bookmark property adds or removes a bookmark. The following sample shows how to bookmark the current line: Edit1.Bookmark(Edit1.CaretLine) = True |
|
The BookmarksList property specifies the list of bookmarks in the control. Use the Bookmark property to bookmark a specified line. The following sample prints all lines that are bookmarked:
The BookmarksList property can be used also to set the list of bookmarks in the control like in the following sample ( the old list of bookmarks is cleared ): Dim l(3) As Long l(0) = 1 l(1) = 3 l(2) = 5 l(3) = 7 Edit1.BookmarksList = l The BookmarksList property supports only unidimension arrays of long elements. |
|
The SelText property returns or sets the string containing the currently selected text. The following sample displays the selected text as soon as the user changes the selection:
|
|
The SelChange event occurs when user selects text in the control. The SelChange event is called also when the position of the cursor is changed. The following sample displays the position of the cursor:
|
|
The Context.Options(exContextAllowChars) as String specifies the list of characters that are allowed to a context list. By default, the Context.Options(exContextAllowChars) property is "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz". For instance, if user presses any of the characters that are not included to Context.Options(exContextAllowChars) property the context list is closed. The exContextAllowChars value is 1. The following sample includes numbers to the Context.Options(exContextAllowChars) property, and so when user presses any of the number keys the context list is not closed, instead it tries to search the matching item:
|
| Yes. The Context.Options( Option as ContextOptionEnum) As Variant property. Specifies an option for the sensitive context list. The Context.Options(exContextCaseSensitive) as Boolean specifies whether the selection of items into a sensitive context list is case sensitive. By default, the Context.Options(exContextCaseSensitive) is False. For instance, if Context.Options(exContextCaseSensitive) is True, the selection of items from a context list is case sensitive. The exContextCaseSensitive value is 0. |
|
The Sort method of the Context object helps you to sort the items in the list. The items are sorted by SortOrder number. The Sort method sorts alphabetically the list of items that have the same SortOrder parameter. Use the Add method of the Context object to specifies the SortOrder number. The following sample sorts the list of items as follows:
and the list of items is 'c', 'b', 'a'. The following sample sorts the list as follows:
and the list of items is 'a', 'b', 'c'.
and the list of items is 'a', 'c', 'b'. All items that are added using the Add method without specifying the SortOrder parameter, have 0 for the SortOrder by default. |
|
The control provides the BookmarkChange event that occurs when user adds or removes a bookmark. The BookmarkChange event occurs when a change occurs in the list of control's bookmarks. The following sample displays the line where user adds a bookmark:
|
|
The ContextMenuItems property specifies a list of items that control adds to its context menu when it is invoked. The AllowContextMenu property specifies whether the control displays its context menu when user right click the control. The list of items is separated by 'New Line' (\n or chr(10)) or 'Carriage return' (\r or chr(13) character. The ExecuteContextMenu event is fired when user selects an user item from the control's context menu. A separator item is added if the caption of the item is empty. The following sample adds few items to the control's context menu:
|
|
Yes. The BackColorLine property specifies the line's background color. The following sample shows how to assign an icon and a background color to the caret line:
The following sample removes the assigned icon and the line's background:
|
| The BookmarkImage property let's you specify the index of icon being displayed whether the line is bookmarked. If the icon doesn't exist the control uses the default shape for drawing bookmarks. Use the Images property to add icons at runtime, or use the control's panel image list to add new icons at design time. Use the BookmarkImageLine property to assign an icon for a particular line. |
The
exEdit 1.0.3.1 defines multiple lines expressions using the
AddExpression method. The following sample adds an expression to
define comments between /* and */:
For instance, the expression /* just a comment */ shows like: /* just a comment */ |
The
exEdit 1.0.3.4 introduces the IgnorePrefixInExpression
property that specifies a collection of prefixes that are ignored
inside an expression. For instance if we have defined an
expression for strings like follows:
In this case we have defined the expression ". So, if the user types in the control the text: 'This is a string "this is a quote \" bla ... bla \" "' the control displays the line like follows: 'This is a string "this is a quote \" bla ... bla \" "' , but we want to ignore \" expressions. In this case we need to use the following code:
In this case, if the user types: 'This is a string "this is a quote \" bla ... bla \" "' the control displays: ''This is a string "this is a quote \" bla ... bla \""' , and this is what we need. The IgnorePrefixInExpression property is cumulative, so you can add multiple prefixes to be ignored for an expression like in the following sample:
Passing an empty string to the IgnorePrefixInExpression property clears the collection of the prefixes for the expression, so the .IgnorePrefixInExpression("""") = "" clears all prefixes previously defined for an expression ("). |
| The
version 1.0.3.4 introduces the OnContext
event that's fired if the control is not read only, and the user
opens the control's context menu ( pressing the CTRL + SPACE key
combination ). The OnContext event passes the context string and
the position where the context begins. Use the OnContext event to
notify your application that the user asks for a context. For
instance, during the OnContext event you can add a collection of
the items, based on the context you have, using the Add
method of the Context
object. Use the CaretPos
and CaretLine
properties to determine the position of the cursor inside the
text. Use the TextLine
property to retrieve line at the cursor.
The following sample displays the current line when the OnContext event occurs:
|
The
ContextKey
property specifies the key combination to display the control's
context window. By default, the key combination to open the
control's context window is CTRL + SPACE. The low byte of the
ContextKey property specifies the code of the key, and the high
byte of the lowest word of the ContextKey property is a bit
combination of the CTRL, SHIFT and ALT keys state. The following
formula should be used to specify a key combination:
ContextKey = (KeyCode) + (256 * ( 1 * Ctrl + 2 * Alt + 4 * Shift) ) where:
For instance, if you need to change the key combination to ALT + SPACE you need to define the ContextKey property like bellow:
or
since the code for SPACE key is 32. By default, the ContextKey property is 288. If you need to have a combination like SHIFT + CTRL + F1 you need to define the ContextKey property like follows:
How can I find the key code? The easiest way to find out the code for a key is to add a handler for KeyDown event like follows:
Important to notice is that the control's context window is not the control's context menu. The control's context window is shown when user presses the ContextKey combination, instead the control's context menu is displayed when user does a right click. |
| The
version 1.0.3.4 introduces the ability to define the keywords or
expressions that include multiple HTML tags.
For instance, the following sample shows how to define the 'class' keyword ( the word is bolded, and the first letter is underlined ):
The following sample adds a '// TODO ..bla bla.... ' expression: With Edit1
.AddExpression "<fgcolor=008000>// <u>TODO</u></fgcolor>", "<b><fgcolor=000080> </fgcolor></b>", ""
End With
|
Use
the MarkColor
property to mark the positions for expressions on the control's
vertical scroll bar. The Expression parameter of the MarkColor
property should not contain the HTML tags. For instance, the
following sample defines /* */ multiple lines expression:
|
| The Locked property specifies whether the text can be edited. Use the Enabled property to disable the control. |
The
problem is that the MDI frame view app handles the CTRL+C, CTRL+V
keys combinations to update the project's menu. The situation is
similar with a view that contains an edit control, in this case,
the project's form view class is derived the CEditView class. For
instance, you can check the MFC source code, where you will find
the onEditCopy function that looks like following:
void CEditView::OnEditCopy()
{
ASSERT_VALID(this);
GetEditCtrl().Copy();
ASSERT_VALID(this);
}
As you can see, when user presses the CTRL+C keys combination the frame calls the Copy method of the edit control. We need to do something similar if out CFormView class contains an exEdit control. You need to insert Windows Message handlers for identities like ID_EDIT_COPY, ID_EDIT_PASTE, ID_EDIT_CUT, and so on. The header file should contain: //{{AFX_MSG(CMyFormView)
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnEditCut();
//}}AFX_MSG
And the implementation file looks like: void CMyFormView::OnEditCopy()
{
m_edit.SendMessage( WM_COMMAND, MAKEWPARAM(0, 0xE122), NULL );
}
void CMyFormView::OnEditCut()
{
m_edit.SendMessage( WM_COMMAND, MAKEWPARAM(0, 0xE123), NULL );
}
void CMyFormView::OnEditPaste()
{
m_edit.SendMessage( WM_COMMAND, MAKEWPARAM(0, 0xE125), NULL );
}
where the m_edit is the wrapper class of the Exontrol's exEdit as member in the CMyFormView object. Check the How do I implement menu functions such as Cut, Copy, Find, Replace, Paste, Undo or Redo? to get the identifiers you can use. |
| The
Cursor
property specifies the cursor that control displays when the mouse
pointer hovers a part of the control. The ClientAreaEnum
type defines the parts of the control where the cursor can be
changed.
The following VB sample changes the cursor when the mouse pointer is over the line number bar: With Edit1
.Cursor(exLineNumberArea) = "exCross"
End With
The following VB.NET sample changes the cursor with a value that Cursors object defines: AxEdit1.Ctlset_Cursor(EXEDITLib.ClientAreaEnum.exLineNumberArea, Cursors.PanEast.Handle) |
The
CTRL + } combination looks for opposite bracket, while the
character at the cursor is '(', '[' or '{'. The following sample
simulates the CTRL + } combination using the CTRL + F1
combination:
Private Sub Edit1_KeyDown(KeyCode As Integer, Shift As Integer)
If (KeyCode = vbKeyF1) Then
KeyCode = 221
End If
End Sub
|
| By
default, when the control performs drag and drop operations, it is
trying to move the block from the source to copy it to the target,
so since the Character Map tool doesn't allow deleting the
dragging character, the control displays no drop cursor. Instead,
if you press the CTRL key while the cursor hovers the control, the
selected character in the Character Map tool can be copied to your
control. Also, you can handle the OLEDragOver
event so, only exOleDropEffectCopy(1) operations are performed
like follows:
The handler just changes the Effect parameter to 1 which is the identifier for exOLEDropEffectCopy (Drop results in a copy of data from the source to the target. The original data is unaltered by the drag operation). |