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 Show The Current Cursor Position

View On-Line Sample
Return to main How To Page

Displaying the Page Number, Line Number, Character Number and Column Number for the Current Cursor Location

By using the below properties you can display the current cursor location in a Label or StatusBar control. Create a subroutine that can be called in the Form_Load Event, ALLText_KeyUp & ALLText_Click Events (this reads and displays the current cusor location on application startup, using the keyboard and mouse).

Example:

Sub Update_StatusBar()

Dim lngCurrentPageNumber As Long, lngCurrentLineNumber As Long
Dim lngCurrentColumnNumber As Long, IntCurrentCharacterInLine As Integer

'Set variable values
lngCurrentPageNumber = ATX451.PageNumber + 1
lngCurrentLineNumber = ATX451.PageLineNumber + 1
lngCurrentColumnNumber = ATX451.CurChar + 1
IntCurrentCharacterInLine = ATX451.CharInLine + 1

'Read values into status bar
StatusBar.Panels.Item(1).Text = "Page " & lngCurrentPageNumber & " Ln " _
& lngCurrentLineNumber & " Char " & IntCurrentCharacterInLine & " Col " &
lngCurrentColumnNumber

End Sub

Private Sub ATX451_Click()

'UPDATE STATUS BAR ON MOUSE CLICK
Call Update_StatusBar

End Sub

Private Sub ATX451_KeyUp(KeyCode As Integer, Shift As Integer)

'UPDATE STATUS BAR ON EVERY KEY PRESS
Call Update_StatusBar

End Sub

Private Sub Form_Load()

With ATX451

'Set document width property to equal 6 inches
.DocWidth = 1440 * 6

'Set printer dc to true
.PrinterDC = True

'Set page hieght property to equal 9 inches
.PageHeight = 1440 * 9

'Turn on show pages property (to display soft page breaks on screen)
'- Extended Features License Option Required
.ShowPages = 1

'INITIALIZE STATUS BAD DATA
Call Update_StatusBar
End With

End Sub

PageNumber Property

Description: Sets or Returns the current page number of the document. Page numbering begins at 0.

Syntax:

ALLText.PageNumber = n%
n% = ALLText.PageNumber

Access:
Read Write
Design - -
Run + +

Remarks: If text is not formatted using the printer device context (ALLText.PrinterDc = False) , ALLText assumes that the contents of the control occupy a single page with length equal to MAX_LONG. In this case, the value of the PageNumber property is always equal to zero.

Setting this property repositions the caret to the specified page number.

PrinterDc Property

Description: Determines whether ALLText uses the Printer Device Context for formatting text on the screen. If this property is set to TRUE the hard copy output and the display will be the same (True WYSIWYG). If set to FALSE, ALLText uses the proper device context for the screen resulting in an enhanced on-screen presentation. (this may cause the on-screen word wrapping to be different from printed word wrapping.

Syntax:

ALLText.PrinterDC = Boolean
b% = ALLText.PrinterDC

Default: False

DataType: Boolean

Access:
Read Write
Design + +
Run + +

Remarks: The following properties are affected by setting of the PrinterDC property.

PageHeight - always set to Max_Long, if PrinterDC = False
PageLineNumber - is equal to LineNumber, if PrinterDC = False
PageNumber - is set to 0 , if PrinterDC = False

PageLineNumber Property

Description: Determines the cursor position in terms of a given line on the current page. The number of the first line on a page is equal to 0.

Syntax:

ALLText.PageLineNumber = l&
l& = ALLText.PageLineNumber

Remarks: If text was not formatted using the printer device context (PrinterDC = False), ALLText assumes that the content of the control occupies a single page whose length is equal to MAX_LONG. In this case the value of PageLineNumber property is equal to number of lines from the start of the document to the current cursor position (ie the LineNumber property).

On setting this property the caret is positioned to the specified line number on the current page (see PageNumber property).

CurChar Property

Description: Read/Set - Setting moves the cursor/caret to the nth character within the current paragraph (as defined by the CurPar property), simultaneously determining the starting edge of a select region. Reading returns either the current cursor/caret offset into a paragraph (if Select property is False), or the character offset of the starting edge of the select region (if Select property is set True)

Syntax:

ALLText.CurChar = n%
n% = ALLText.CurChar

Access:
Read Write
Design - -
Run + +

DataType: Integer

Values: 0 <= n% <= Number of Characters in the Paragraph specified by CurPar property

Default: 0

Remarks: If out of range this property is set to last Character of the Paragraph specified by CurPar property.

CharInLine Property

Description: Read/Set - Setting moves the cursor/caret to the nth character within the current line (as defined by the CurPar property), Reading returns either the current cursor/caret offset into a line.

Syntax:

ALLText.CharInLine = n%
n% = ALLText.CharInLine

Access:
Read Write
Design - -
Run + +

DataType: Integer

Values: 0 <= n% <= Number of Characters in the line specified by CurPar property

Default: 0

Remarks: If out of range this property is set to last Character of the line specified by CurPar property.


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