万分感谢

crwlr 2002-03-16 05:24:43
在pb中如何实现类似于在vb中的选择某个路径?
也就是如何象安装向导一样,选择的是某个目录,而不是某一个文件。望大家赐教。
比如:我备份数据,想要备份到某个路径,这个路径如何让用户来进行选择。而不是手工输入路径。
...全文
54 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
llitcwl 2002-03-16
用API,这有个老外写的,封装好了,倒进PBL就可以了:
$PBExportHeader$nvo_folderbrowse.sru
$PBExportComments$文件夹浏览器,可返回文件夹string
forward
global type nvo_folderbrowse from nonvisualobject
end type
end forward
type shitemid from structure
unsignedint cb
character abid
end type
type itemidlist from structure
shitemid mkid
end type
type browseinfo from structure
unsignedlong howner
unsignedlong pidlroot
string pszdisplayname
string lpsztitle
unsignedint ulflags
unsignedlong lpfn
long lparam
integer iimage
end type

global type nvo_folderbrowse from nonvisualobject autoinstantiate
end type
type prototypes
Protected:
Function unsignedlong SHGetPathFromIDListA( unsignedlong pidl, ref string pszPath) Library 'shell32'

Function unsignedlong SHBrowseForFolderA( browseinfo lpbrowseinfo ) Library 'shell32'

Subroutine CoTaskMemFree(ulong idlist) Library 'ole32'
end prototypes
type variables
Protected:
unsignedLong BIF_RETURNONLYFSDIRS = 1
end variables
forward prototypes
public function string browseforfolder (window awi_parent, string as_caption)
public function string browseforfolder (window awi_parent, string as_caption)
end prototypes
public function string browseforfolder (window awi_parent, string as_caption);
/********************************************************************
BrowseForFolder
<DESC> Open the browse for folder dialog and return the
selected directory.</DESC>
<RETURN> String: Folder Selected.</RETURN>
<ACCESS> Public
<ARGS> awi_Parent: Parent Window.
as_Caption: Caption to display on dialog.</ARGS>

<USAGE> lnca_BFF.BrowseForFolder( parent, 'caption!' )</USAGE>
********************************************************************/

browseinfo lstr_bi
itemidlist lstr_idl
unsignedlong ll_pidl
unsignedlong ll_r
Integer li_pos
String ls_Path
unsignedlong ll_Null
SetNull( ll_Null )
lstr_bi.hOwner = Handle( awi_Parent )
lstr_bi.pidlRoot = 0
lstr_bi.lpszTitle = as_caption
lstr_bi.ulFlags = bif_ReturnOnlyFSDirs
lstr_bi.pszDisplayName = Space( 255 )
lstr_bi.lpfn = ll_Null
ll_pidl = SHBrowseForFolderA( lstr_bi )
ls_Path = Space( 255 )
ll_R = SHGetPathFromIDListA( ll_pidl, ls_Path )
CoTaskMemFree( ll_pidl )
RETURN ls_Path
end function
on nvo_folderbrowse.create
TriggerEvent( this, "constructor" )
end on
on nvo_folderbrowse.destroy
TriggerEvent( this, "destructor" )
end on
event constructor;
/*******************************************************************
nca_FolderBrowse: Display a folder selection dialog. <EXCLUDE>
<OBJECT> Access the win32 API and open the Browse For Folder
Dialog. Then return the name of the folder selected.
</OBJECT>
<USAGE> nvo_browseforfolder lnca_BFF
ls_Folder = lnca_BFF.BrowseForFolder( parent, 'Pick folder' )
</USAGE>
<AUTHOR>
Date Ref Author Comments

07/16/98 1 Ken Howe First Version
08/24/98 1.1 Matthew Royle Changed to work with PB5.0
06/03/99 1.2 Ken Howe Added CoTaskMemFree, based on a
Discussion on the PB News group and
also this ise used in many VB examples.
********************************************************************/
// This is a code example:
/*
nva_folderbrowse lnca_bff
String ls_A
ls_A = lnca_BFF.BrowseForFolder( parent, 'pick your folder' )
MessageBox( 'You Picked', ls_A )
*/
end event
回复
侠雨飞飞 2002-03-16
呵呵~~,是GetFileOpenName()
回复
Eric2000 2002-03-16
changeDirectry()
回复
侠雨飞飞 2002-03-16
用getfileopen()函数
可以看一下PB帮助,很详细的
回复
相关推荐
发帖
非技术版
创建于2007-09-28

379

社区成员

PowerBuilder 非技术版
申请成为版主
帖子事件
创建了帖子
2002-03-16 05:24
社区公告
暂无公告