Dear All,
How to scroll two textboxes(txtbox1,txtbox2 ) simultaneously.That is if i scroll the txtbox1 then txtbox2 automatically and viceversa.
Printable View
Dear All,
How to scroll two textboxes(txtbox1,txtbox2 ) simultaneously.That is if i scroll the txtbox1 then txtbox2 automatically and viceversa.
Quote:
Originally Posted by danasegarane
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!
Dear amrita,
Thanks for the reply.Can you post some more info like in which textbox event i have to call this?
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.
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 eventQuote:
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.Quote:
Originally Posted by danasegarane
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
Take a look at this thread. Maybe you want to consider using a Vscroll1 for your two textboxes.
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?
Have you tried the method DigiRev mentioned ?
It is not working.It is working for veritcal lines only.
Any suggestions?
Change the constant for Horizontal - WM_HSCROLL
(You will need to find the Value)
I tried like this,but not working
VB Code:
'***************From MSDN***************************** 'r& = SendMessage&(hWd%, EM_LINESCROLL, wParam%, lParam&) ' ' hWd% The window handle of the text box. ' wParam% Parameter not used. ' lParam& The low-order 2 bytes specify the number of vertical ' lines to scroll. The high-order 2 bytes specify the ' number of horizontal columns to scroll. A positive ' value for lParam& causes text to scroll upward or to the ' left. A negative value causes text to scroll downward or ' to the right. ' r& Indicates the number of lines actually scrolled. 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 Const WM_HSCROLL As Long = &H114 Private Sub Command1_Click() 'Scroll to the 10 the charcters r& = SendMessage&(Text1.hwnd, WM_HSCROLL, 0&, ByVal -10&) End Sub