|
-
Oct 19th, 2000, 04:09 PM
#1
Thread Starter
New Member
How does one use a Horizontoal Scroll control to change two textboxes simultaneously? If I output a database to a textbox, I want to put the fieldnames in one and the data in another.
Then I want to scroll to see the stuff on the far edge and have both boxes scroll together, keeping the Fieldname aligned with the Data.
-
Dec 19th, 2002, 07:41 AM
#2
Member
No one's ever Cracked this
I did a search for my current predicament and this post matched it perfectly - but D'oh! No response?
Have we all failed?
-
Dec 19th, 2002, 07:53 AM
#3
I'm pretty sure you'll need to subclass
VB Code:
'*************
'* In a form *
'*************
Option Explicit
Private Sub Form_Load()
Call InitText
Call Hook(Text1.hwnd)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call Unhook(Text1.hwnd)
End Sub
Private Sub InitText()
Dim x As Integer
For x = 1 To 40
Text1.Text = Text1.Text & "Test" & vbCrLf
Next
Text2.Text = Text1.Text
End Sub
'************************
'* In a standard module *
'************************
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _
ByVal hwnd As Long, _
ByVal Msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Private Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) _
As Long
Private Const GWL_WNDPROC = (-4)
Private Const WM_VSCROLL = &H115
Private mPrevProc As Long
Public Sub Hook(ByVal hwnd As Long)
mPrevProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WndProc)
End Sub
Public Sub Unhook(ByVal hwnd As Long)
Call SetWindowLong(hwnd, GWL_WNDPROC, mPrevProc)
mPrevProc = 0&
End Sub
Public Function WndProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
If uMsg = WM_VSCROLL Then
Call SendMessageLong(Form1.Text2.hwnd, uMsg, wParam, lParam)
End If
If mPrevProc Then
WndProc = CallWindowProc(mPrevProc, hwnd, uMsg, wParam, lParam)
Else
WndProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
End If
End Function
Assumes a form called Form1, that has two textboxes (Text1 and Text2)
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
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
|