Now Available!

Native .Net
Components

TList WinForms
for
.Net Framework

&

MetaDraw WinForms
for
.Net Framework



Bennet-Tec
Components
Make you
look sharp!



Home

Company

Products

Order Forms

How To

Downloads

Updates

Support

Registration

Dependencies

Links

Compatibility

Site Map


Basic How To


How To Implement a Highlight Pen with ALLText

NOTE: Requires Extended Features License

When the click event is fired in ALLText a subroutine is called that checks the state of a checkbox. If checked (in highlight mode) ALLText will select and Highlight text when the mouse is clicked and dragged along the text. It will then turn off the select when the mouse button is released, highlighting only the text you have selected. To remove the highlight from the text, perform the same steps that added the highlight.

The state of the checkbox determines if you are in highlight mode or not.

Un-checked - highlight mode is off.
Checked - highlight mode is on.

To create a Highligh Pen in ALLText you will need to place a checkbox control on a form with an ALLText control. You can use the checkbox control as a button or a checkbox (user defined).

Directions:

  1. Place an ALLText control & a checkbox on a form
  2. Craete a subroutine (example: Activate_HLpen) that will check the state of the checkbox and will do the following:
    • If the user is selecting text and the font back color is not set then
    • Apply the highlighted color to the selected text and turn off the select
    • Else If the user is selecting text and the font back color is set then
    • Remove the highlighted color from the selected text and turn off the select
  3. Call the subroutine in the ALLText click event to process the users actions

View On-Line Sample
Return to main How To Page

Example:

Sub Activate_HLpen()

'Check to see what the state of the checkbox is

If ChkHighLight.Value <> 0 Then 'If checked then
With ATX451
'If selecting and the font back color is not set to a color
'then apply the chosen color from the dialog control
If .Select And .FontBackColor = -1 Then
'Apply the highlight
If DlgColor.Color = vbWhite Then
.FontBackColor = -1
Else
.FontBackColor = DlgColor.Color
.Select = 1
End If
Else
'If highlight is applied remove from the selected area
If .FontBackColor <> -1 Then
.FontBackColor = -1
.Select = 1
End If
'Deselect and move cursor to end
If .FontBackColor = -1 Then
'If following text not highlit, then set highlight at
'current position to none
.FontBackColor = -1
End If
'Otherwise, further typing will be within
'bounds of the highlight
End If
End With
Else
Exit Sub
End If

End Sub

Select Property

Description: The Select property may be used as a flag. It returns a value of TRUE when a select region is active and FALSE if no region is currently selected.

The property may also be set in order to turn off a select region. On setting Select to 0 caret goes to the start of selected area and text is unselected. On setting Select to 1 the caret goes to the end of the selected area and after that text is unmarked.

Syntax:

n% = ALLText.Select
ALLText.Select = n%

Access:
ReadWrite
Design--
Run++

Data Type: Integer

Values:

  • -1 (TRUE) - Some text is selected. This value may NOT be set.
  • 0 (FALSE) - No text is currently selected.Setting to 0 deselects text and moves cursor to Start of select region.
  • 1 (Move to end) - No text is currently selected. Setting to 1 deselects text and moves cursor to end of select region. This value is never returned when reading the property.

Example:

If AllText1.Select<>TRUE then
  AllText1.SelToPar = AllText1.CurPar+1
  AllText1.SelToChar = 0
End If

NOTE: Select will be turned off whenever the SelLength has a value of 0.
Examples: SelSTart = SelStart + SelLength, or setting CurPar = SelToPar and CurChar = SelToChar.

FontBackColor Property

Description: FontBackColor has been added to ALLText with extended version support providing for setting the background color of a selected region of text. This is ideal for highlighting key words such as when a document is presented in response to a full text search on a database.

Syntax: ALLText.FontBackColor = Color&

Values:

  • Default: -1 (no FontBackColor)
  • Set to: -1 or QBColor(n) (we can use only solid colors)
  • Return Value -1, indicates no background color
  • ATX_UNDEF indicates mixed back colors within selection or an RGB Value indicates background color

Supported RTF Code: "\highlightN " where N is an integer in the range -1, or 1 to 16 (-1 indicates no font backcolor)

DefFontName DefFontSize properties - allow easy changes to default font

ATX_GetCurrentLineText function - returns text on current line


Copyrightę 2003 Bennet-Tec Information Systems, Inc. All rights reserved.