Results 1 to 2 of 2

Thread: scroll a listbox and a textbox

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2006
    Posts
    52

    scroll a listbox and a textbox

    k, this one's a real challenge. Is there a way that you can make a listbox scroll at the same position as a textbox is scrolled at? for example, I'm trying to make an html code editor and I want the listbox which contains the line numbers, to scroll at the same position of the textbox so the user can see what line they are on.
    Thanks 4 the help

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Re: scroll a listbox and a textbox

    Okay the following code works but the problem is that there isn't a scroll event for the textbox so I put the code in a command button.Maybe you can find a way to use it.

    VB Code:
    1. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _
    2.                                          wParam As Long, lParam As Long) As Long
    3. Private Const EM_GETFIRSTVISIBLELINE = &HCE
    4. Private Const EM_LINEINDEX = &HBB
    5.  
    6.  
    7. Private Sub command1_Click()
    8.     Dim lngLine As Long
    9.     Dim lngChar As Long
    10.    
    11.     With Text1
    12.         ' Find the line number of the first visible line
    13.         lngLine = SendMessageLong(.hwnd, EM_GETFIRSTVISIBLELINE, 0&, 0&)
    14.     End With
    15.    
    16.     List1.ListIndex = lngLine
    17.  
    18. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width