home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5430
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 6675
- LinkTopic = "Form1"
- ScaleHeight = 5430
- ScaleWidth = 6675
- StartUpPosition = 3 'Windows Default
- Begin MSComctlLib.StatusBar StatusBar1
- Align = 2 'Align Bottom
- Height = 285
- Left = 0
- TabIndex = 1
- Top = 5145
- Width = 6675
- _ExtentX = 11774
- _ExtentY = 503
- _Version = 393216
- BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
- NumPanels = 1
- BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
- Alignment = 2
- Object.Width = 8819
- MinWidth = 8819
- EndProperty
- EndProperty
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- End
- Begin RichTextLib.RichTextBox text1
- Height = 4065
- Left = 30
- TabIndex = 0
- Top = 780
- Width = 5805
- _ExtentX = 10239
- _ExtentY = 7170
- _Version = 393217
- Enabled = -1 'True
- TextRTF = $"Form1.frx":0000
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- End
- Begin VB.Label Label1
- Caption = "Label1"
- Height = 495
- Left = 120
- TabIndex = 2
- Top = 90
- Width = 5655
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' Name: DispCaretPos
- ' By: Herman Liu
- Option Explicit
- Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
- (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
- Private Const EM_GETSEL = &HB0
- Private Const EM_LINEINDEX = &HBB
- Private Const EM_LINEFROMCHAR = &HC9
- Dim overallCursorPos As Long
- Dim currLinePos As Long
- Dim chrsBeforeCurrLine As Long
- Dim CurrLineCursorPos As Long
- Private Sub Form_Load()
- Label1.Caption = "Type serveral lines for trial. As you type or move" & _
- " the cursor, statusbar updates the current line and character position"
- End Sub
- Private Sub Text1_Change()
- DispCaretPos
- End Sub
- Private Sub Text1_Click()
- DispCaretPos
- End Sub
- Private Sub text1_KeyUp(KeyCode As Integer, Shift As Integer)
- DispCaretPos
- End Sub
- Private Sub DispCaretPos()
- On Local Error Resume Next
- 'cursor position in the text box (incl CR & LF if any)
- '(Note zero-based)
- overallCursorPos = SendMessageLong(text1.hwnd, EM_GETSEL, 0, 0&) \ &H10000
- 'current line pos (Note: zero-based)
- currLinePos = SendMessageLong(text1.hwnd, EM_LINEFROMCHAR, overallCursorPos, 0&)
- 'number of chrs upto but before start of the current line
- ' (incl CR & LF f any)
- chrsBeforeCurrLine = SendMessageLong(text1.hwnd, EM_LINEINDEX, _
- currLinePos, 0&)
- 'cursor position in terms of current line only (Note: zero-based)
- '
- CurrLineCursorPos = overallCursorPos - chrsBeforeCurrLine
- text1.SetFocus
- ' Note, for example, if you only have 2 sections of the status
- ' bar, then change 3 to 2 below.
- StatusBarMsg "Pos: " & CStr(currLinePos + 1) & ":" & _
- CStr(CurrLineCursorPos + 1) & Space(1), 1
- End Sub
- Private Sub StatusBarMsg(mMsg As String, mPanel As Integer)
- StatusBar1.Panels(mPanel).Text = mMsg
- StatusBar1.Refresh
- End Sub
-