请问如何显示一个让用户选择目录的dialog?(如windows自身带的.)(无内容)

pauper 2001-06-08 11:00:00
...全文
227 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainmanboy 2001-06-12
  • 打赏
  • 举报
回复
我来告诉你 流方的个人网站上有!
tanye 2001-06-11
  • 打赏
  • 举报
回复
把下面的脚本命名为nvo_dir_browser.sru,
然后Import到你的pbl中,使用见constructor

$PBExportHeader$nvo_dir_browser.sru
$PBExportComments$Shell32 API functions
forward
global type nvo_dir_browser from nonvisualobject
end type
type browseinfo from structure within nvo_dir_browser
end type
end forward

type BROWSEINFO from structure
long hwndOwner
long pidlRoot
string pszDisplayName
string lpszTitle
ulong ulFlags
ulong lpfn
ulong lParam
long iImage
end type

global type nvo_dir_browser from nonvisualobject autoinstantiate
end type

type prototypes
// Shell functions
Function long SHBrowseForFolder( Ref BROWSEINFO lpBi ) Library "shell32.dll"
Function boolean SHGetPathFromIDList( long pIDL, Ref String pszPath ) Library "shell32.dll" Alias For "SHGetPathFromIDListA"
end prototypes

type variables
// MAX_PATH constant for file operations
Private constant long MAX_PATH = 260
// SHBrowseForFolder constants
Private:
constant ulong BIF_RETURNONLYFSDIRS = 1 // Browse for directory
constant ulong BIF_DONTGOBELOWDOMAIN = 2 // For starting the Find Computer
constant ulong BIF_STATUSTEXT = 4
constant ulong BIF_RETURNFSANCESTORS = 8
constant ulong BIF_EDITBOX = 16
constant ulong BIF_BROWSEFORCOMPUTER = 4096 // Browse for computer
constant ulong BIF_BROWSEFORPRINTER = 8192 // Browse for printers
constant ulong BIF_BROWSEINCLUDEFILES = 16384 // Browse for everything
end variables

forward prototypes
public function string of_browseforfolder (long alhparent, string asprompt)
private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags)
end prototypes

public function string of_browseforfolder (long alhparent, string asprompt);
//===================================================================
// Function: of_BrowseForFolder()
//-------------------------------------------------------------------
// Description:Macro function to call of_SHBrowseForFolder with correct
// BIF_xxx constant
//-------------------------------------------------------------------
// Parameters: alhParent (LONG)
// asPrompt (STRING)
// alhParent
// Handle of the owner window for the dialog box.
// asPrompt
// Text to go in the banner over the tree.
//-------------------------------------------------------------------
// Returns: Returns the selected folder name.
//===================================================================
RETURN This.of_SHBrowseForFolder( alhParent, asPrompt, BIF_RETURNONLYFSDIRS )

end function

private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags);
//===================================================================
// Function: of_SHBrowseForFolder()
//-------------------------------------------------------------------
// Description:Displays a dialog box that enables the user to select
// a shell folder.
//-------------------------------------------------------------------
// Parameters: alhParent (LONG)
// asPrompt (STRING)
// alFlags (LONG)
// alhParent
// Handle of the owner window for the dialog box.
// asPrompt
// Text to go in the banner over the tree.
// alFlags
// A combination of the BIF_xxx constant flags
//-------------------------------------------------------------------
// Returns: Returns the folder/printer/computer name.
//===================================================================
long llIDList
BROWSEINFO lBI
string lsPath
// Populate the BROWSEINFO structure
lBI.hWndOwner = alhParent // Handle of parent window
lBI.pidlRoot = 0 // Use default namespace root
lBI.pszDisplayName = Space( MAX_PATH ) // Allocate space for the returned buffer
lBI.lpszTitle = asPrompt // Text to go in the banner above the tree
lBI.ulFlags = alFlags // BIF_xxx flags
lBI.lpfn = 0 // No callback function
lBI.lParam = 0 // Extra info for callbacks
lBI.iImage = 0 // Output var: where to return the Image index
// SHBrowseForFolder returns a pointer to an item identifier list that
// specifies the location of the selected folder.
llIDList = SHBrowseForFolder( lBI )
IF (llIDList > 0) THEN
// Allocate space before calling API function
lsPath = Space( MAX_PATH )
// Extract path name from IDList
IF NOT SHGetPathFromIDList( llIDList, lsPath ) THEN
// Error extracting path
lsPath = ""
END IF
ELSE
// User pressed CANCEL, or error in selecting path
lsPath = ""
END IF
RETURN Trim(lsPath)

end function

on nvo_dir_browser.create
call super::create
TriggerEvent( this, "constructor" )
end on

on nvo_dir_browser.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

event constructor;
//Demo
/*
string lsDestination
nvo_browser luoShell
lsDestination = upper(luoShell.of_BrowseForFolder(Handle(This), "选择上报数据库存放路径:"));
IF Len(lsDestination) > 0 THEN
if right(lsDestination,1) <> '\' then lsDestination = lsDestination + '\';
END IF
*/
end event

<完>
szjlq 2001-06-11
  • 打赏
  • 举报
回复
我有一个从网上下载的用户对象,可调用WINDOWS的标准目录对话框
本想贴出来,但看了那N个结构就头痛啦,你给我EMAIL我发给你吧,
我记得网上有很多地方有这个例子呀
pauper 2001-06-11
  • 打赏
  • 举报
回复
getfileopenname("select file",docname,named)
只是取文件啊,我要只选目录.
「已注销」 2001-06-11
  • 打赏
  • 举报
回复
这是我在SDK中看到的 我还没完全整明白 中国电脑教育报上曾介绍过在VB下调用的例子

查一查 应该不难 这是标准的WIN的选择目录函数



SHBrowseForFolder

[Now Supported on Windows NT]

Displays a dialog box that enables the user to select a shell folder.

WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(

LPBROWSEINFO lpbi
);


Parameters

lpbi

Pointer to a BROWSEINFO structure that contains information used to display the dialog box.



Return Values

Returns a pointer to an item identifier list that specifies the location of the selected folder relative to the root of the name space. If the user chooses the Cancel button in the dialog box, the return value is NULL.
The calling application is responsible for freeing the returned item identifier list using the shell's task allocator.

See Also

BROWSEINFO

sailerbai 2001-06-08
  • 打赏
  • 举报
回复
upstair
有道理,要是能够自己写一个就更好了!
goldg 2001-06-08
  • 打赏
  • 举报
回复
pb里的确没有直接选取目录的控件,使用pb直接写也可以,当在处理目录结构的时候,很难办。PB7里有一个例子,不过他是将目录树一次读进来,如果目录结构比较复杂,读目录树可能要几分钟,而windows下的控件根据当前目录逐级展开的。使用API SHBrowseForFolder可以调用windows的目录选择控件,不过你最好用C写一个DLL,在PB中调用.
mouseonline 2001-06-08
  • 打赏
  • 举报
回复
up
pauper 2001-06-08
  • 打赏
  • 举报
回复
GetFileOpenName 只是取文件,不可取目录啊.请再指教.
pauper 2001-06-08
  • 打赏
  • 举报
回复
GetFileOpenName 只是取文件,不可取目录啊.请再指教.
caolei1974 2001-06-08
  • 打赏
  • 举报
回复
同意
ping_ping 2001-06-08
  • 打赏
  • 举报
回复
GetFileOpenName
chinajb 2001-06-08
  • 打赏
  • 举报
回复
在PB。4Y4Y。NET中好象有这样的下载,是一个pb做的窗口
netmuse 2001-06-08
  • 打赏
  • 举报
回复
improtfile即可
pauper 2001-06-08
  • 打赏
  • 举报
回复
请大家关注一下啦.
  • 打赏
  • 举报
回复
有这方面的控件,pb里应该有啊
sclt 2001-06-08
  • 打赏
  • 举报
回复
getfileopenname("select file",docname,named)
pauper 2001-06-08
  • 打赏
  • 举报
回复
我看PB中的dirlist()和dirselect()象是可以的,但不知如何控制就列出目录.各位有此经验否?

1,076

社区成员

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

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