Results 1 to 14 of 14

Thread: Scrollbar in Textbox

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Scrollbar in Textbox

    Dear All,
    How to scroll two textboxes(txtbox1,txtbox2 ) simultaneously.That is if i scroll the txtbox1 then txtbox2 automatically and viceversa.
    Please mark you thread resolved using the Thread Tools as shown

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Scrollbar in Textbox

    Quote Originally Posted by danasegarane
    Dear All,
    How to scroll two textboxes(txtbox1,txtbox2 ) simultaneously.That is if i scroll the txtbox1 then txtbox2 automatically and viceversa.

    Here is the Code ( I picked it up from Google Groups)

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, _
    ByVal lParam As Long) As Long
    Const WM_VSCROLL = &H115
    Const SB_LINEDOWN = 1
    Const SB_LINEUP = 0

    Private Sub VScroll1_Change()
    SendMessage Text1.hwnd, WM_VSCROLL, SB_LINEDOWN, ByVal 0
    SendMessage Text2.hwnd, WM_VSCROLL, SB_LINEDOWN, ByVal 0
    End Sub

    Hope this helps!

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    Dear amrita,
    Thanks for the reply.Can you post some more info like in which textbox event i have to call this?
    Please mark you thread resolved using the Thread Tools as shown

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Scrollbar in Textbox

    The only way I can think of is subclassing.

    I'm not sure what the constant is for a scrollbar (WM_VSCROLL?). Or if you would even receive the message from the textbox.

    You could try subclassing for the scroll message, and when it's received, send it to the other textbox via SendMessage.

    Then again that's just a guess, I have no idea if that would work.

  5. #5
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Scrollbar in Textbox

    Quote Originally Posted by danasegarane
    Dear amrita,
    Thanks for the reply.Can you post some more info like in which textbox event i have to call this?
    I didn't get ur question.Are u using 2 textboxes with a common vertical scroll bar? write the code in the scroll bar change event

  6. #6

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    I am using two textboxes.Both the textboxes their scrollbars.What I want is ,How to other textbox when the any of the text box is scrolled
    Please mark you thread resolved using the Thread Tools as shown

  7. #7
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Scrollbar in Textbox

    Quote Originally Posted by danasegarane
    I am using two textboxes.Both the textboxes their scrollbars.What I want is ,How to other textbox when the any of the text box is scrolled
    I found out how.

    You need to subclass the textbox.

    And when you receive the WM_VSCROLL message, you need to scroll the other textbox via SendMessage.

    You can find out how to scroll another textbox programatically here:

    http://support.microsoft.com/kb/73371

  8. #8
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Scrollbar in Textbox

    Take a look at this thread. Maybe you want to consider using a Vscroll1 for your two textboxes.

  9. #9

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    Dear Zynder,
    Thanks for the link.It is very nice.But I face one problem.When I scroll by using the keydown or up\down arrow it is not working.Is there any method?
    Please mark you thread resolved using the Thread Tools as shown

  10. #10
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Scrollbar in Textbox

    Have you tried the method DigiRev mentioned ?
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  11. #11

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    It is not working.It is working for veritcal lines only.
    Last edited by danasegarane; Jan 23rd, 2007 at 11:48 AM.
    Please mark you thread resolved using the Thread Tools as shown

  12. #12

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    Any suggestions?
    Please mark you thread resolved using the Thread Tools as shown

  13. #13
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Scrollbar in Textbox

    Change the constant for Horizontal - WM_HSCROLL

    (You will need to find the Value)

  14. #14

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Scrollbar in Textbox

    I tried like this,but not working
    VB Code:
    1. '***************From MSDN*****************************
    2. 'r& = SendMessage&(hWd%, EM_LINESCROLL, wParam%, lParam&)
    3. '
    4. '     hWd%     The window handle of the text box.
    5. '     wParam%  Parameter not used.
    6. '     lParam&  The low-order 2 bytes specify the number of vertical
    7. '              lines to scroll. The high-order 2 bytes specify the
    8. '              number of horizontal columns to scroll. A positive
    9. '              value for lParam& causes text to scroll upward or to the
    10. '              left. A negative value causes text to scroll downward or
    11. '              to the right.
    12. '     r&       Indicates the number of lines actually scrolled.
    13. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
    14. Const WM_HSCROLL As Long = &H114
    15. Private Sub Command1_Click()
    16.     'Scroll to the 10 the charcters
    17.     r& = SendMessage&(Text1.hwnd, WM_HSCROLL, 0&, ByVal -10&)
    18. End Sub
    Please mark you thread resolved using the Thread Tools as shown

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