dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: PowerBuilder
Expertise: Beginner
Oct 18, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Creating a "Browse for Folder" Dialog Box

Question:
How can I create a "browse" facility in my application—something which throws up a dialog box that allows the user to view folders and select one, as in Microsoft Explorer, without selecting a specific file within it?

Answer:
This is not a built-in feature of PowerBuilder; it requires the use of the Windows API. To begin with, create a new non-visual object and create the following local structures:

 
structure shitemid 
unsignedint        cb
character        abid

structure itemidlist
shitemid        mkid

structure browseinfo
unsignedlong        howner
unsignedlong        pidlroot
string        pszdisplayname
string        lpsztitle
unsignedint        ulflags
unsignedlong        lpfn
long        lparam
integer        iimage
Add the following API calls to the local external functions:
 
Function unsignedlong &
   SHGetPathFromIDListA( unsignedlong pidl, ref string pszPath) Library 'shell32'
Function unsignedlong &
   SHBrowseForFolderA( browseinfo lpbrowseinfo ) Library 'shell32'
Subroutine CoTaskMemFree( ulong idlist ) Library 'ole32'
Create a function with the following arguments and return value:
 
string browseforfolder (window awi_parent, string as_caption)
In this function add the following code:
 
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 = 1
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
Save the object and in your script, create the object call the browseforfolder function, and then destroy the object.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date