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
Select a folder without using the cGetDir function RESOLVED
Select a folder without using the cGetDir function RESOLVED
Last edited by MaxP on Thu Nov 28, 2024 10:00 am, edited 1 time in total.
Re: Select a folder without using the cGetDir function
In this case it is possible to select a folder or file
Code: Select all | Expand
#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. )
Re: Select a folder without using the cGetDir function
Thank you Natter,
but I didn't want to use the cGetDir function,
searching online I found that you could use the IFileDialog interface
(from Windows Vista)
but I didn't want to use the cGetDir function,
searching online I found that you could use the IFileDialog interface
(from Windows Vista)
Re: Select a folder without using the cGetDir function
Code: Select all | Expand
cGetFile()
cGetDir()
cGetDir32()
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Re: Select a folder without using the cGetDir function
Sorry, MaxP ! I could only achieve this design for the “Save As” function
- Antonio Linares
- Site Admin
- Posts: 42259
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Select a folder without using the cGetDir function
Working fine:
Code: Select all | Expand
#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
Re: Select a folder without using the cGetDir function
Thank you very much Antonio,
this is exactly what I was looking for,
you are always our boss
Good day
this is exactly what I was looking for,
you are always our boss
Good day