Win32 API 函数 SHAutoComplete 是实现该功能的关键,它的 Powersoft 原型是:
SHACF_AUTOAPPEND_FORCE_ON 1073741824 忽略注册表的缺省值并强行打开自动添加功能。
SHACF_AUTOSUGGEST_FORCE_OFF 536870912 忽略注册表的缺省值并强行关闭自动建议功能。
SHACF_AUTOSUGGEST_FORCE_ON 268435456 忽略注册表的缺省值并强行打开自动建议功能。
SHACF_DEFAULT 0 缺省值,等价于SHACF_FILESYSTEM | SHACF_URLALL。
SHACF_FILESYSTEM 1 包括文件系统和虚拟文件夹。
SHACF_URLALL 6 包括用户历史和最近使用列表中的URL。
SHACF_URLHISTORY 2 包括用户历史列表中的URL。
SHACF_URLMRU 4 包括最近使用列表中的URL。
SHACF_USETAB 8 允许用户按Tab键选择建议选项列表。
// dwFlags: SHACF_USETAB | SHACF_FILESYSTEM | SHACF_URLALL = 15
SHAutoComplete(Handle(this), 15)
拖放功能
DragAcceptFiles(Handle(this), true)
w_main.Event Close( ) returns long
DragAcceptFiles(Handle(this), false)
UInt lui_index // 文件索引值 (基于0)
UInt lui_filenum // 文件数
String ls_filename // 文件名
lui_filenum = DragQueryFileA(handle, -1, ls_filename, 256) // 获取文件数
DragQueryFileA(handle, lui_index, ls_filename, 256) // 获取文件名
if sle_autocom.text <> "" then sle_autocom.text += " " // 在文件名间放置空格
if PathIsLFNFileSpecA(ls_fileName) then
ls_fileName = '"' + ls_fileName + '"' // 长文件名加双引号
end if
sle_autocom.text += ls_fileName
next
DragFinish(handle) //释放内存
发表于 @ 2007年01月10日 22:20:00 | 评论( 3 ) | 编辑| 举报| 收藏
1.我声明了这个external function:
Subroutine DragAcceptFiles(ULong hWnd,Boolean fAccept) Library "Shell32.dll"
2.在窗口的open事件中加了代码:DragAcceptFiles(Handle(this), true)
为什么拖拽文件到窗口时,鼠标仍然是不可拖拽的标志呢,相应的窗口pbm_dropfiles的事件也不能执行,哪里有问题?
keyssoft 发表于2007年2月8日 03:00:01 IP:举报
/*Required IDE: PB 10 or later*/
forward
global type w_main from window
end type
end forward
integer width = 1262
integer height = 540
boolean titlebar = true
string title = "Untitled"
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
event dropfiles pbm_dropfiles
end type
global w_main w_main
Subroutine DragAcceptFiles(ULong hWnd, Boolean fAccept) Library "Shell32.dll"
Subroutine DragFinish(ULong hDrop) Library "Shell32.dll"
Function ULong DragQueryFileW(ULong hDrop, ULong iFile, ref String lpszFile, ULong cch) Library "Shell32.dll"
Function Boolean PathIsLFNFileSpecW(String pszName) Library "Shlwapi.dll"
end prototypes
UInt lui_filenum // 文件数
String ls_filename // 文件名
DragQueryFileW(handle, lui_index, ls_filename, 256)
MessageBox("DropFiles", ls_filename);
next
end event
end on
end on
end event
1、窗口在打开时需是OPEN方式,如果是OPENSHEET方式打开的窗口不能接收拖拽事件,在应用程序中可以写在MDI窗口中。
2、在PB8和PB9中拖拽多次或打开其他窗口时,很容易死机,在DragQueryFileA之前需设一下参数ref String lpszFile,让lpszFile有一个初始的长度,例如256个空格之类。
http://blog.csdn.net/keyssoft/archive/2007/01/10/1479618.aspx