ho trovato questo codice in un file .bas
codice:
Public PrevProc As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
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
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_VSCROLL = &H115
Public Const GWL_WNDPROC As Long = (-4)
Public Function cbScroll(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'if uMsg is 'WM_VSCROLL' then wParam will be 0 or 1.
'0 signifies scrolling upwards, and 1 downwards
'Process the default window message
cbScroll = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam)
'If the messege sent was a scroll message, scroll the other two textboxes
If uMsg = WM_VSCROLL Then
'SendMessage is my friend
retVal = SendMessage(frmMultipleScroll.txtScroll(1).hwnd, WM_VSCROLL, wParam, Null)
retVal = SendMessage(frmMultipleScroll.txtScroll(2).hwnd, WM_VSCROLL, wParam, Null)
End If
End Function
e nel form ci sta questo codice
codice:
Private Sub Command1_Click()
'Scroll the first textbox. This, in turn will scroll the other two
retVal = SendMessage(txtScroll(0).hwnd, WM_VSCROLL, 0, Null)
End Sub
Private Sub Command2_Click()
'Scroll the first textbox. This, in turn will scroll the other two
retVal = SendMessage(txtScroll(0).hwnd, WM_VSCROLL, 1, Null)
End Sub
Private Sub Form_Load()
'Subclass the first Textbox
PrevProc = SetWindowLong(txtScroll(0).hwnd, GWL_WNDPROC, AddressOf cbScroll)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Release the subclassed Textbox
SetWindowLong txtScroll(0).hwnd, GWL_WNDPROC, PrevProc(q)
End Sub
NON RIESCO AD USARLO . Qualcuno si è mai cimentato in questa impresa? Grazie e ciao