问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

vb OLEDrag OLEDrop

发布网友 发布时间:2022-05-03 07:41

我来回答

1个回答

热心网友 时间:2023-10-14 18:29

分二步:
'一、新建一个模块,复制下面代码到模块中
Option Explicit
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SendMessageByNum Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetForegroundWindow Lib "User32" () As Long
Private Declare Function GetClassName Lib "User32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SetCapture Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "User32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetParent Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "User32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const PROCESS_TERMINATE = &H1
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const CB_GETCURSEL = &H147
Private Const CB_GETLBTEXTLEN = &H149
Private Const CB_GETLBTEXT = &H148

Private Type POINTAPI
X As Long
Y As Long
End Type

Function GetPath() As String
Dim lu_POINT As POINTAPI, Curwindow As Long, parentWnd As Long
Dim S As String, Hwd As Long, K As Long, Recn As Long
Call GetCursorPos(lu_POINT)
Curwindow = WindowFromPoint(lu_POINT.X, lu_POINT.Y)
parentWnd = GetParent(Curwindow)
Do While parentWnd <> 0
Curwindow = GetParent(parentWnd)
If Curwindow = 0 Then Exit Do
parentWnd = Curwindow
Loop
Hwd = parentWnd
S = String(254, 0)
K = GetClassName(Hwd, S, 254)
S = StrConv(LeftB(StrConv(S, vbFromUnicode), K), vbUnicode)

Select Case LCase(S)
Case "cabinetwclass"
Hwd = FindWindowEx(Hwd, 0, "WorkerW", vbNullString)
Hwd = FindWindowEx(Hwd, 0, "ReBarWindow32", vbNullString)
Hwd = FindWindowEx(Hwd, 0, "ComboBoxEx32", vbNullString)
Recn = SendMessage(Hwd, CB_GETCURSEL, K, 0)
K = SendMessageByNum(Hwd, CB_GETLBTEXTLEN, Recn, 0)
If K > 0 Then
GetPath = String(K, 0)
SendMessageByString Hwd, CB_GETLBTEXT, Recn, GetPath
If GetPath = "我的文档" Then
GetPath = CreateObject("Wscript.Shell").SpecialFolders("MyDocuments")
End If
End If
Case "progman"
GetPath = CreateObject("Shell.Application").Namespace(&H10).self.Path
End Select

End Function

'二、当鼠标拖动结束时 ,调用下面函数即可获得外部已打开的那个文件夹的路径 :
dim Path as string
Path=GetPath

'三、至于复制文件的问题,不说你也知道了,在此略去不提。

热心网友 时间:2023-10-14 18:29

分二步:
'一、新建一个模块,复制下面代码到模块中
Option Explicit
Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
lParam As Any) As Long
Private Declare Function SendMessageByNum Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessageByString Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function FindWindow Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "User32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetForegroundWindow Lib "User32" () As Long
Private Declare Function GetClassName Lib "User32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetWindowText Lib "User32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function SetCapture Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "User32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetParent Lib "User32" (ByVal hWnd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "User32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const PROCESS_TERMINATE = &H1
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const CB_GETCURSEL = &H147
Private Const CB_GETLBTEXTLEN = &H149
Private Const CB_GETLBTEXT = &H148

Private Type POINTAPI
X As Long
Y As Long
End Type

Function GetPath() As String
Dim lu_POINT As POINTAPI, Curwindow As Long, parentWnd As Long
Dim S As String, Hwd As Long, K As Long, Recn As Long
Call GetCursorPos(lu_POINT)
Curwindow = WindowFromPoint(lu_POINT.X, lu_POINT.Y)
parentWnd = GetParent(Curwindow)
Do While parentWnd <> 0
Curwindow = GetParent(parentWnd)
If Curwindow = 0 Then Exit Do
parentWnd = Curwindow
Loop
Hwd = parentWnd
S = String(254, 0)
K = GetClassName(Hwd, S, 254)
S = StrConv(LeftB(StrConv(S, vbFromUnicode), K), vbUnicode)

Select Case LCase(S)
Case "cabinetwclass"
Hwd = FindWindowEx(Hwd, 0, "WorkerW", vbNullString)
Hwd = FindWindowEx(Hwd, 0, "ReBarWindow32", vbNullString)
Hwd = FindWindowEx(Hwd, 0, "ComboBoxEx32", vbNullString)
Recn = SendMessage(Hwd, CB_GETCURSEL, K, 0)
K = SendMessageByNum(Hwd, CB_GETLBTEXTLEN, Recn, 0)
If K > 0 Then
GetPath = String(K, 0)
SendMessageByString Hwd, CB_GETLBTEXT, Recn, GetPath
If GetPath = "我的文档" Then
GetPath = CreateObject("Wscript.Shell").SpecialFolders("MyDocuments")
End If
End If
Case "progman"
GetPath = CreateObject("Shell.Application").Namespace(&H10).self.Path
End Select

End Function

'二、当鼠标拖动结束时 ,调用下面函数即可获得外部已打开的那个文件夹的路径 :
dim Path as string
Path=GetPath

'三、至于复制文件的问题,不说你也知道了,在此略去不提。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
Linux系统安装FTP服务器 Linux系统的网络文件共享 建筑的七盏明灯的内容简介 面向对象设计七大原则 简单说 交互设计七大定律 交互设计的“根”——七大定律 交互设计原则和理论2——七大定律 七大设计原则 附近的加油站有哪些 附近的加油站有哪些地方 qyragmet.exe损坏的图像 怎么解决 请教excel vba高手,如何按行循环一段代码直到某内容则停止 我的keil没有rag52.h头文件 如图??? 雷霆之怒,逐风剑服务器是唯一的1把吗? excel 中如何将用公式或其他方式实现包含0-9其中一个数字的统计出来 老大,您能告诉我excel中B列连续相同的值所对应同行A列值的平均值么 WOW职业专属台词 大众全新SUV渲染图曝光 内部代号Raggdzzi 将于2023年发布 魔兽III冰封问题RAG1:哪个地图(战役)有50000金矿?? insragrem是什么官方的网站吗? 一个正方体每边的电阻为R,求对角总电阻值(RAG) RAG格式是什么,怎么打开? 操作系统,画出当前状态系统RAG图 《嫁值连城》epub下载在线阅读全文,求百度网盘云资源 嫁值连城电子书txt全集下载 《嫁值连城》epub下载在线阅读,求百度网盘云资源 《嫁值连城》的结局到底是什么 《嫁值连城》最新txt全集下载 自制纳豆的做法步骤图,自制纳豆怎么做好吃 如如何烙饼好吃 MATLAB 中[H,T,P]什么意思? mysql语句自连接问题 每个人的是不是只有一份纸质档案?还是说还有另外的备份,或者电子档?那每一份内容是一模一样的吗?_百度问一问 江苏这边学生2021年毕业生都没有纸质档案吗 高三纸质档案和电子档案有什么区别,区别有多大? 大学生毕业后公司提档,个人有电子档案么?公司提档是不是只有纸版档案。 大学录取或者以后工作主要是看电子档案还是纸质档案 高中纸质档案拿到大学,大学把档案拆开吗? 大学毕业后档案里有高考电子档案吗? 新生档案是什么东西? 考试毕业后电子档案与档案的区别是什么??谢谢 大学生档案是什么档案?是电子档案,还是文字档案? 高考之前确认档案 还是高考之后 是纸质档案还是电子档案 毕业后签哪些单位要档案,档案指的是纸质还是电子的 淀粉粘蟹怎么做 螃蟹的做法大全 如何做螃蟹料 世界上消失的国家,位于尼泊尔与不丹之间是哪一个? 锡金为什么现在是印度领土,而不是一个国家 中国承认锡金属于印度,换取了什么? 被阿三吞并的主权国家锡金还有复国的可能么?为什么?