Hey
I am having some trouble with using BrowseForFolder.. for a start i dont really kno how to do it :grin:
but when the user clicks on the open button i want it to show a browseforfolder box and then the user can select a folder and the folder path will go into a text box

i think the path has something to do with bi.pidlRoot but I cant seem to get it working so if anyone can help i would be greatful
Posted on 2001-09-28 01:46:05 by Kezza
try the following sample:



xor eax, eax
mov lpPIDL, eax

lea eax, lpPIDL
push eax
push CSIDL_DRIVES
push hwndDlg
call SHGetSpecialFolderLocation
test eax, eax
jne dirExit

mov edi, lpszPath

xor ecx, ecx
lea eax, xBrowseInfo
mov ebx, hwndDlg
mov [eax.bri_hwndOwner], ebx
mov edx, lpPIDL
mov [eax.bri_pidlRoot], edx
mov [eax.bri_lpszDisplay], edi
mov [eax.bri_lpszTitle], offset szTitle
mov [eax.bri_ulFlags], BIF_RETURNONLYFSDIRS
mov [eax.bri_lpfn], ecx
mov [eax.bri_lParam], ecx
mov [eax.bri_iImage], ecx

push eax
call SHBrowseForFolder
test eax, eax
je dwcFree

push edi
push eax
call SHGetPathFromIDList
test eax, eax
je dwcFree

push edi
push IDC_DIR_PATH
push hwndDlg
call SetDlgItemText

dwcFree: push lpPIDL
call CoTaskMemFree
Posted on 2001-09-28 03:30:55 by beaster
Hi thanx for that
do i need to put anything in the .data, .data? or .const sections?
and do i just put that code after .if ax==IDB_OPEN
if i want to open the browseforfolder box when the user clix on the open button?
thanx
Posted on 2001-09-28 03:38:08 by Kezza
well, you need a BROWSEINFO structure in the data section,
a pointer for the root path and lpszPath containing the initial
path to show as well as the resulting path.



.data

lpszPath: dd ?
lpPIDL: dd ?
xBrowseInfo BROWSEINFOA <?>
szTitle: db "Choose a path:", 0


if you work in a dialog, the parent window is hwndDlg. Maybe
the members of the BROWSEINFO structure are named
different in your assembler. Take a look in the shlobj.inc
include file. szTitle must contain the dialogs title.
Posted on 2001-10-01 04:27:49 by beaster