|
-
Jan 9th, 2007, 11:28 AM
#1
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
-
Jan 11th, 2007, 03:06 AM
#2
Re: Scrollbar in Textbox
 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!
-
Jan 11th, 2007, 03:23 AM
#3
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
-
Jan 11th, 2007, 03:33 AM
#4
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.
-
Jan 11th, 2007, 03:44 AM
#5
Re: Scrollbar in Textbox
 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
-
Jan 11th, 2007, 03:50 AM
#6
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
-
Jan 11th, 2007, 04:00 AM
#7
Re: Scrollbar in Textbox
 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
-
Jan 11th, 2007, 04:04 AM
#8
Re: Scrollbar in Textbox
Take a look at this thread. Maybe you want to consider using a Vscroll1 for your two textboxes.
-
Jan 23rd, 2007, 10:02 AM
#9
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
-
Jan 23rd, 2007, 11:38 AM
#10
Re: Scrollbar in Textbox
Have you tried the method DigiRev mentioned ?
-
Jan 23rd, 2007, 11:42 AM
#11
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
-
Jan 24th, 2007, 05:34 AM
#12
Please mark you thread resolved using the Thread Tools as shown
-
Jan 24th, 2007, 05:43 AM
#13
Re: Scrollbar in Textbox
Change the constant for Horizontal - WM_HSCROLL
(You will need to find the Value)
-
Jan 24th, 2007, 06:38 AM
#14
Re: Scrollbar in Textbox
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
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|