急!500分求:鼠标拖动超连接,获得 连接地址 和 连接文本 [现在只能获得连接地址,头痛!!!]

躺卧青草地 2004-10-13 11:32:40
已开一贴:
http://community.csdn.net/Expert/topic/3452/3452550.xml?temp=.5529291
可惜没人回答,到时一起给分,和再开3贴转分!



Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
MsgBox Data.GetData(vbCFText)
End Sub

以上代码,只能获得超连接的,连接地址,头痛!

必给分!

...全文
234 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
问题解决!多谢!baoaya(点头)! 结贴2! 另开3贴转分!请各位理解!
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
TO baoaya(点头): 楼上是高人阿~ 你那真的可以获得连接和文本了? 能否作个 EXE 传给我呢?

QQ: 39832783

多谢!
lxcc 2004-10-14
  • 打赏
  • 举报
回复
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

假如你把超连接选中再托得到的是连接文本,不选直接托就是连接地址
至于同时得到两个,关注,至少falshget可以做到选中连接,然后托动连接可以得到两个
行云边 2004-10-14
  • 打赏
  • 举报
回复
反正使用Data.GetData(-16246) 取得的是FILEGROUPDESCRIPTOR 数据结构
typedef struct _FILEGROUPDESCRIPTOR {
UINT cItems;
FILEDESCRIPTOR fgd[1];
} FILEGROUPDESCRIPTOR, *LPFILEGROUPDESCRIPTOR;
typedef struct _FILEDESCRIPTOR {
DWORD dwFlags;
CLSID clsid;
SIZEL sizel;
POINTL pointl;
DWORD dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
DWORD nFileSizeHigh;
DWORD nFileSizeLow;
TCHAR cFileName[MAX_PATH];
} FILEDESCRIPTOR, *LPFILEDESCRIPTOR;

TCHAR cFileName[MAX_PATH]; 里面包含的是 连接文本

cFileName 的offset正好是76 所以我直接使用
strTxt = Mid(strTxt, 76/2+1, Len(strTxt) - 76/2-1 + 1)
来取得cFileName ,你可以使用正规的方法来取得
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
TO baoaya(点头) :真的吗?! 那太好了! 麻烦你再改改! 实在不行,做个EXE 给大伙试试吧!谢谢!
行云边 2004-10-14
  • 打赏
  • 举报
回复
我自己测试了
我的电脑里是可以的

要不我再改改
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
TO baoaya(点头): 试了,只能显示地址 5555555```
TO lxcc(虫子|需要点勇气和信心): 您给我的那2个列子,正在看中,谢谢!
TO everyone : 谢谢你们的关注!

TO BlueBeer(1win): 影音传送(NetTransport),网络快车, 网络蚂蚁,他们都可以在拖动连接的时候,获得连接文本,显示在跳出对话框中,请问他们是怎么实现的呢? 我看过他们的获得连接页面脚本,发上来,不知道有没有用
-----------------------------------------------
影音传送(NetTransport):

<script language = "VBScript">
'Download all links
'Net Transport Copyright (C) 2001-2004 By Kevin Wang

On Error Resume Next

set NTIECatcher = CreateObject("NTIEHelper.NTIEAddUrl")
if err = 0 then
set links = external.menuArguments.document.links
set images = external.menuArguments.document.images
ReDim hrefs(links.length + images.length)
ReDim remarks(links.length + images.length)

for i = 0 to links.length - 1
hrefs(i) = links(i).href
remarks(i) = links(i).innerText
next
for j = 0 to images.length - 1
hrefs(i) = images(j).href
remarks(i) = images(j).Alt
i = i + 1
next

if i > 0 then
call NTIECatcher.AddList(external.menuArguments.document.Url, hrefs(0), remarks(0))
end if
end if

</script>
================================================================================

FlashGet:
<script language="VBScript">
'Great thanks to Vladimir Romanov(Author of ReGet Pro)

On Error Resume Next
set JetCarCatch=CreateObject("JetCar.Netscape")
if err<>0 then
MsgBox("FlashGet not properly installed!"+ vbCrLf+"Please Install FlashGet again")
else
set links = external.menuArguments.document.links
ReDim params(links.length*2)
params(0)=external.menuArguments.document.Url
for i = 0 to links.length-1
params(i*2+1)=links(i).href
params(i*2+2)=links(i).innerText
next
JetCarCatch.AddUrlList params
end if
</script>

----------------------------------------------------------------------------



行云边 2004-10-14
  • 打赏
  • 举报
回复
不知道行不行 ,行的话给点分 呵呵
Option Explicit

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strTxt As String, strURL As String
On Error Resume Next
strTxt = Data.GetData(-16246)
strURL = Data.GetData(vbCFText)
strTxt = Mid(strTxt, 39, Len(strTxt) - 39 + 1)
strTxt = Left(strTxt, InStr(1, strTxt, Chr(0)) - 1 - 4)
MsgBox "连接文本:" & strTxt
MsgBox "连接地址:" & strURL
End Sub
shamefei 2004-10-14
  • 打赏
  • 举报
回复
关注中,顶~~~
lxcc 2004-10-14
  • 打赏
  • 举报
回复
http://www.fawcette.com/vsm/2002_07/magazine/columns/qa/default.aspx
只是泛泛而谈,实际例子也不外乎上面的代码

是DotNET的例子,可以不考虑
http://www.syncfusion.com/FAQ/WinForms/FAQ_c54c.asp
14.4 How to get the hyperlink and the hyperlink text dragged from IE in my Control's drag-drop event?


继续关注ing
lxcc 2004-10-14
  • 打赏
  • 举报
回复
http://www.fawcette.com/vsm/2002_07/magazine/columns/qa/default.aspx

http://www.syncfusion.com/FAQ/WinForms/FAQ_c54c.asp
14.4 How to get the hyperlink and the hyperlink text dragged from IE in my Control's drag-drop event?

踏平扶桑 2004-10-14
  • 打赏
  • 举报
回复
个强烈关注中。。。
BlueBeer 2004-10-14
  • 打赏
  • 举报
回复
不行的,和你的代码一样,需要用户选中文本才能得到文本,没有意义
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
运行通过后,马上结2贴分,转3贴分! 共500分!
躺卧青草地 2004-10-14
  • 打赏
  • 举报
回复
劳驾楼上兄台,好事作到底吧,这个代码我也找到过,之怪自己不才,没能用到,老家兄台能否帮组织排版下, 只要能这样就成!多谢!

Text1.Text = Url
Text2.Text = UrlText

多谢!
韧恒 2004-10-14
  • 打赏
  • 举报
回复
解决?可不可以详细点写出来,我试的怎么不行?
躺卧青草地 2004-10-13
  • 打赏
  • 举报
回复
不懂和想知道的兄弟,帮忙一起UP啊!

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧