根本不用Delphi,如果接受IE中的文本,利用VB几行代码就可以: Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) If Data.GetFormat(vbCFText) Then Text1.Text = Data.GetData(vbCFText) End If End Sub 运行前将text1的Oledropmode设定为1。然后从IE中选择拖放文本到Text1上就可以了。
同意TechnoFantasy(www.applevb.com) 其实很简单,有空多看msdn吧
那他那个像FLASHGET一样的悬浮框怎么做呢?
做一个没有标题的小窗口,然后设定为总在最前: Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongConst HWND_TOPMOST = -1Private Sub Form_Load() SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX _ , Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, _ Me.Height \ Screen.TwipsPerPixelY, 0 End Sub
谢谢!只是如何接受从资源管理器或是WORD中拖过来的字符或是文本文档呢?
If Data.GetFormat(vbCFText) Then '字符串 Text1.Text = Data.GetData(vbCFText) End If If Data.GetFormat(vbCFFiles) Then '文件 Text1.Text = Data.GetData(vbCFText) End If
十分抱歉,前面的关于文件处理的代码错了,应该是这样: Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) If Data.GetFormat(vbCFFiles) Then '文件 For i = 1 To Data.Files.Count List1.AddItem Data.Files(i) Next i End If End Sub 那么当拖动文件到Form上就会在List1中列出文件。
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFText) Then
Text1.Text = Data.GetData(vbCFText)
End If
End Sub
运行前将text1的Oledropmode设定为1。然后从IE中选择拖放文本到Text1上就可以了。
其实很简单,有空多看msdn吧
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter
As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags
As Long) As LongConst HWND_TOPMOST = -1Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX _
, Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, _
Me.Height \ Screen.TwipsPerPixelY, 0
End Sub
Text1.Text = Data.GetData(vbCFText)
End If
If Data.GetFormat(vbCFFiles) Then '文件
Text1.Text = Data.GetData(vbCFText)
End If
Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFFiles) Then '文件
For i = 1 To Data.Files.Count
List1.AddItem Data.Files(i)
Next i
End If
End Sub
那么当拖动文件到Form上就会在List1中列出文件。