• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 888
  • Last Modified:

VB6 RTB set first visible line

Dear Experts,

In VB6, how can I set the first visible line of a rich textbox? If it is on line 2 or greater, I want to set it to current first visible line minus 1.

Thanks!
0
ttobin333
Asked:
ttobin333
  • 2
1 Solution
 
Martin LissRetired ProgrammerCommented:
Option Explicit

Private Declare Function SendMessage Lib "user32.dll" _
 Alias "SendMessageA" ( _
   ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   ByRef lParam As Any) As Long
Const EM_GETFIRSTVISIBLELINE = &HCE
Const EM_LINESCROLL = &HB6
Private Sub Command1_Click()
  
Dim FirstVisibleLine As Long

FirstVisibleLine = SendMessage(RichTextBox1.hwnd, EM_GETFIRSTVISIBLELINE, 0, ByVal 0&)
If FirstVisibleLine > 1 Then ' lines are zero based
    SendMessage RichTextBox1.hwnd, EM_LINESCROLL, 0, ByVal -1
End If
End Sub

Open in new window

0
 
ttobin333Author Commented:
Thanks!
0
 
Martin LissRetired ProgrammerCommented:
You're welcome and I'm glad I was able to help.

My profile contains links to some articles I've written that may interest you.
Marty - MVP 2009 to 2012
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now