以下是引用sych在2022-3-17 08:21:08的发言:
取不了目录
取不了目录
这个是取文件名对话框,取文件夹对话框是另一个API,有空可以写个示例。
IF nDialogType==0 AND nLen > 0 **cPaht = cFiles cPaht = ADDBS(cFiles) cFiles = "" DO WHILE nLen > 0 && 多选 **cFiles = cFiles + cPaht + "\" + SYS(2600, pFile, nLen) + 0h0D0A cFiles = cFiles + cPaht + SYS(2600, ptr, nLen) + 0h0D0A ptr = ptr + nLen + 1 nLen = apiStrlen(ptr) ENDDO cFiles = RTRIM(cFiles,0h0D0A) ENDIF
[此贴子已经被作者于2022-3-18 04:36编辑过]
** Browsing for directory. #define BIF_RETURNONLYFSDIRS 0x0001 && For finding a folder to start document searching #define BIF_DONTGOBELOWDOMAIN 0x0002 && For starting the Find Computer #define BIF_STATUSTEXT 0x0004 && Top of the dialog has 2 lines of text for BROWSEINFO.lpszTitle and one line if && this flag is set. Passing the message BFFM_SETSTATUSTEXTA to the hwnd can set the && rest of the text. This is not used with BIF_USENEWUI and BROWSEINFO.lpszTitle gets && all three lines of text. #define BIF_RETURNFSANCESTORS 0x0008 #define BIF_EDITBOX 0x0010 && Add an editbox to the dialog #define BIF_VALIDATE 0x0020 && insist on valid result (or CANCEL) #define BIF_NEWDIALOGSTYLE 0x0040 && Use the new dialog layout with the ability to resize && Caller needs to call OleInitialize() before using this API #define BIF_USENEWUI (BIF_NEWDIALOGSTYLE + BIF_EDITBOX) #define BIF_BROWSEINCLUDEURLS 0x0080 && Allow URLs to be displayed or entered. (Requires BIF_USENEWUI) #define BIF_BROWSEFORCOMPUTER 0x1000 && Browsing for Computers. #define BIF_BROWSEFORPRINTER 0x2000 && Browsing for Printers #define BIF_BROWSEINCLUDEFILES 0x4000 && Browsing for Everything #define BIF_SHAREABLE 0x8000 && sharable resources displayed (remote shares, requires BIF_USENEWUI)
DEFINE CLASS BROWSEINFOA AS STRUCT_CALSS PROCEDURE init DIMENSION this.aSTRUCT[8,4] this.stInit(1, "hwndOwner", "N",4) this.stInit(2, "pidlRoot", "N",4) this.stInit(3, "pszDisplayName", "N",4) this.stInit(4, "lpszTitle", "N",4) this.stInit(5, "ulFlags", "N",4) this.stInit(6, "lpfn", "N",4) this.stInit(7, "lParam", "N",4) this.stInit(8, "iImage", "N",4) STRUCT_CALSS::init ENDPROC ENDDEFINE
DECLARE LONG CoTaskMemFree IN Ole32 LONG DECLARE long ILCreateFromPath IN shell32 string@ DECLARE long SHBrowseForFolder IN shell32 long DECLARE long SHGetPathFromIDList IN shell32 long, long
** ** StructCalss_DirDialog.prg ** #INCLUDE StructCalss.h SET PROCEDURE TO StructCalss.prg ADDITIVE LoadApi() ? myGetDir("C:\temp") SET PROCEDURE TO CLEAR ALL RETURN FUNCTION myGetDir(cDefDir) LOCAL bi, pDir, cDir, pci, pit pDir = apiMalloc(MAX_PATH) cDefDir = STRCONV(ADDBS(cDefDir)+0h00, 5) pci = ILCreateFromPath(@cDefDir) bi = CREATEOBJECT("BROWSEINFOA") bi.setValue("pidlRoot", pci) bi.setValue("pszDisplayName", pDir) bi.setValue("ulFlags", BIF_BROWSEINCLUDEFILES) pit = SHBrowseForFolder(bi.pBuffer) IF pit > 0 SHGetPathFromIDList(pit, pDir) cDir = SYS(2600, pDir, apiStrlen(pDir)) CoTaskMemFree(pit) ENDIF CoTaskMemFree(pci) apiFree(pDir) RETURN cDir ENDFUNC
[此贴子已经被作者于2022-3-17 21:49编辑过]