'参考下面代码:
'首先建立一个窗体,在其上放置四个按钮、一个richtextbox。 窗体模块拷贝以下代码:
Const EM_LINESCROLL = &HB6
Private Declare Function SendMessage Lib "User32" Alias _
"SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Long) As Long
Private Sub Form_Load()
Command1.Caption = "向上一行"
Command2.Caption = "向下两行"
Command3.Caption = "向左三列"
Command4.Caption = "向右四列"
End Sub
Private Sub Command1_Click()
Dim lngRet As Long
lngRet = SendMessage(RichTextBox1.hWnd, EM_LINESCROLL, 0, -1&)
End Sub
Private Sub Command2_Click()
Dim lngRet As Long
lngRet = SendMessage(RichTextBox1.hWnd, EM_LINESCROLL, 0, 2&)
End Sub
Private Sub Command3_Click()
Dim lngRet As Long
lngRet = SendMessage(RichTextBox1.hWnd, EM_LINESCROLL, -3, 0&)
End Sub
Private Sub Command4_Click()
Dim lngRet As Long
lngRet = SendMessage(RichTextBox1.hWnd, EM_LINESCROLL, 4, 0&)
End Sub
Private Sub Form_Load()
Me.OLEDropMode = 1
End Sub
Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sCom As String
sCom = Command
txtFile.Text = sCom & vbCrLf
Dim nCount As Integer, nIndex As Integer
Dim sName As String
With Data
' If .GetFormat(vbCFFiles) = True Then
'sName = .GetData(3)
nCount = .Files.Count
For nIndex = 1 To nCount
txtFile.Text = txtFile.Text & .Files.Item(nIndex) & vbCrLf
Next
' Else
' End If
End With
End Sub