关于GETFILE()函数多选问题,原来人家早给咱准备好了工具
数次遇到GETFILE()函数查找文件时需要多选的问题大家知道:VFP本身的GETFILE()函数是不具备多选功能的
也曾在本坛查找解决方案而不得
今日翻看VFP安装文件夹时无意中看到
原来其中的C:\Program Files\VFP9\Samples\Solution\中文夹中早有解决方案
就在GetFileX.scx中
偶然发现,不敢独享
有相同需要的同学可以借鉴
CLEAR ? GetOpenFiles() FUNCTION GetOpenFiles() LOCAL hProcHeap, lpstrFile, stOPENFILENAME, nRet DECLARE LONG GetProcessHeap IN Kernel32 DECLARE LONG HeapAlloc IN Kernel32 LONG, LONG, LONG DECLARE LONG HeapFree IN Kernel32 LONG, LONG, LONG DECLARE LONG GetOpenFileName IN Comdlg32 STRING@ hProcHeap = GetProcessHeap() lpstrFile = HeapAlloc(hProcHeap, 8, 80*260) stOPENFILENAME = BINTOC(76, "4RS"); + REPLICATE(0h00, 24); + BINTOC(lpstrFile, "4RS"); + BINTOC(80*260, "4RS"); + REPLICATE(0h00, 16); + BINTOC(0x81204, "4RS"); + REPLICATE(0h00, 20) nRet = GetOpenFileName(@stOPENFILENAME) LOCAL i, nOffset, cFile, aFile[1] cFile = "" IF nRet > 0 nOffset = 0 DO WHILE !(SYS(2600, lpstrFile + nOffset, 2) == 0h0000) nOffset = nOffset + 1 IF nOffset > 65536 && 64 * 1024 nOffset = 0 EXIT ENDIF ENDDO cFile = SYS(2600, lpstrFile, nOffset) IF ALINES(aFile, cFile, 0h00) > 1 cFile = "" FOR i = 2 TO ALEN(aFile) cFile = cFile + 0h0D0A + aFile[1] + "\" + aFile[i] ENDFOR cFile = SUBSTR(cFile, 3) ENDIF ENDIF HeapFree(hProcHeap, 1, lpstrFile) RETURN cFile ENDFUNC
CLEAR ? GetFileX() FUNCTION GetFileX() LOCAL of of = CREATEOBJECT("MSComDlg.CommonDialog") *of = CREATEOBJECT("MSComDlg.CommonDialog.1") of.Flags = 0x00080204 && 0x00080000 or 0x00000200 or 0x00000004 of.Filter = "All|*.*|jpg|*.jpg|TXT|*.txt|PRG|*.prg|报表|*.FRX" of.maxFileSize = 10000 of.InitDir = "C:\TEMP" of.FileName = "pp.jpg" of.ShowOpen() && 显示“打开”对话框 *of.ShowSave() && 显示“另存为”对话框 *of.ShowColor() && 显示“颜色”对话框 *of.ShowFont() && 显示“字体”对话框 *of.ShowPrinter() && 显示“打印”或“打印选项”对话框 *of.ShowHelp() && 调用 Windows 帮助引擎 RETURN of.FileName ENDFUNC
[此贴子已经被作者于2015-12-4 22:09编辑过]