Hi all,
I would like to select a folder using a form similar to that for selecting a file,
not like the one used by the cGetDir function.
A form like the example below
Can someone help me ?
Thanks in advance
Massimo
#define BIF_RETURNONLYFSDIRS 0x0001
#define BIF_DONTGOBELOWDOMAIN 0x0002
#define BIF_STATUSTEXT 0x0004
#define BIF_RETURNFSANCESTORS 0x0008
#define BIF_EDITBOX 0x0010
#define BIF_VALIDATE 0x0020
#define BIF_NEWDIALOGSTYLE 0x0040
#define BIF_USENEWUI (BIF_NEWDIALOGSTYLE|BIF_EDITBOX)
#define BIF_BROWSEINCLUDEURLS 0x0080
#define BIF_BROWSEFORCOMPUTER 0x1000
#define BIF_BROWSEFORPRINTER 0x2000
#define BIF_BROWSEINCLUDEFILES 0x4000
#define BIF_SHAREABLE 0x8000
itm:=cGetDir(Title,,,, BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_USENEWUI + ;
BIF_BROWSEINCLUDEFILES + BIF_NONEWFOLDERBUTTON, .T. )
cGetFile()
cGetDir()
cGetDir32()
#include "FiveWin.ch"
function Main()
MsgInfo( GetFolder() )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <shobjidl.h>
#include <stdio.h>
#include <hbapi.h>
LPSTR FW_WideToAnsi( LPWSTR pWide );
void GetFolder()
{
HRESULT hr;
IFileDialog *pFileDialog = NULL;
// Initialize COM library
hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
// Create the File Open Dialog object
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, &IID_IFileDialog, (void **)&pFileDialog);
if (SUCCEEDED(hr))
{
// Set the dialog options to pick folders
DWORD dwOptions;
hr = pFileDialog->lpVtbl->GetOptions(pFileDialog, &dwOptions);
if (SUCCEEDED(hr))
{
hr = pFileDialog->lpVtbl->SetOptions(pFileDialog, dwOptions | FOS_PICKFOLDERS);
if (SUCCEEDED(hr))
{
// Show the dialog
hr = pFileDialog->lpVtbl->Show(pFileDialog, NULL);
if (SUCCEEDED(hr))
{
// Retrieve the selected folder
IShellItem *pItem = NULL;
hr = pFileDialog->lpVtbl->GetResult(pFileDialog, &pItem);
if (SUCCEEDED(hr))
{
PWSTR pszFolderPath = NULL;
hr = pItem->lpVtbl->GetDisplayName(pItem, SIGDN_FILESYSPATH, &pszFolderPath);
if (SUCCEEDED(hr))
{
hb_retc( FW_WideToAnsi( pszFolderPath ) );
CoTaskMemFree(pszFolderPath);
}
pItem->lpVtbl->Release(pItem);
}
}
}
}
pFileDialog->lpVtbl->Release(pFileDialog);
}
else
hb_retc( "" );
}
CoUninitialize();
}
HB_FUNC( GETFOLDER )
{
GetFolder();
}
#pragma ENDDUMP
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 12 guests