` Printed Icetips Article

Icetips Article



Par2: Pick a directory using 32 bit API calls
1998-01-09 -- Jeff Berlinghoff
 
CW4 has this built in, but I needed to be able to do this in CW2. It was easier than I 
expected.


Global Embed, After Global Includes:
BROWSEINFO GROUP,TYPE
hWndOwner       LONG
pIDLRoot            LONG
lpszDisplayName LONG
lpszTitle               LONG
ulFlags                 LONG
lpfnCallBack        LONG
iImage                 LONG
            END

Global Embed, Inside Global Map:
MODULE('Shell32')
  SHBrowseForFolder(*BrowseInfo),LONG,RAW,PASCAL
  SHGetPathFromIDList(Long,*CSTRING),LONG,RAW,PASCAL
  CoTaskMemFree(*LONG),RAW,PASCAL
END

Procedure, Embed, Data
BI          LIKE(BrowseInfo)
cTitle     CSTRING(30)
cPath    CSTRING(251)

In the Code (BE SURE YOU HAVE A WINDOW OPEN!)
cTitle = 'List Title Message'
cPath = '<0>{250}'
BI.hWndOwner = 0{prop:Handle}
BI.lpszTitle = ADDRESS(cTitle)
BI.ulFlags = 1 !only show directories!

lpIDList# = SHBrowseForFolder(BI)
IF lpIDList#
  Result# = SHGetPathFromIDList(lpIDList#, cPath)
  COTaskMemFree(lpIDList#)
  MESSAGE(cPath, 'You Chose')
END



Printed November 21, 2024, 6:57 am
This article has been viewed/printed 35236 times.