|
发表于 2006-3-24 08:22:43
|
显示全部楼层
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.PictureBox Picture1
Height = 855
Left = 240
ScaleHeight = 795
ScaleWidth = 795
TabIndex = 0
Top = 120
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const HWND_TOPMOST = -1
Const SWP_SHOWWINDOW = &H40
Const strWebSite = "你拖放的是网页地址,地址是"
Const strWebImage = "你拖放的是网页图象,图象将保存到PictureBox中"
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 Long
Private Sub Form_Load()
'使Form1可以接受OLE拖放
Form1.OLEDropMode = 1
' 使用Windows API函数SetWindowPos将窗口设置为总在最前面以捕捉拖放操作
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, _
SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
End Sub
Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button _
As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
Effect = vbDropEffectCopy
If Data.GetFormat(vbCFText) Then '拖放的是网页地址
MsgBox strWebSite + Data.GetData(vbCFText)
ElseIf Data.GetFormat(vbCFDIB) Then '拖放的是网页图象
MsgBox strWebImage
Picture1.Picture = Data.GetData(vbCFDIB)
End If
End Sub |
|