Implemented folder picker dialog

This commit is contained in:
locka%iol.ie 1998-11-23 00:03:58 +00:00
parent 70717c02d0
commit d21ed0a69d
3 changed files with 49 additions and 4 deletions

View File

@ -54,8 +54,7 @@ BEGIN
PUSHBUTTON "Pick File...",IDC_SELECTFILE,29,43,55,13
DEFPUSHBUTTON "OK",IDOK,170,5,50,14
PUSHBUTTON "Cancel",IDCANCEL,170,25,50,14
PUSHBUTTON "Pick Folder...",IDC_SELECTFOLDER,89,43,55,13,
WS_DISABLED
PUSHBUTTON "Pick Folder...",IDC_SELECTFOLDER,89,43,55,13
END

View File

@ -62,6 +62,49 @@ void CScanForFilesDlg::OnSelectFile()
void CScanForFilesDlg::OnSelectFolder()
{
// TODO: Add your control notification handler code here
BROWSEINFO bi;
TCHAR szFolder[MAX_PATH + 1];
memset(szFolder, 0, sizeof(szFolder));
memset(&bi, 0, sizeof(bi));
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = szFolder;
bi.lpszTitle = _T("Pick a folder to scan");
// Open the folder browser dialog
LPITEMIDLIST pItemList = SHBrowseForFolder(&bi);
if (pItemList)
{
IMalloc *pShellAllocator = NULL;
SHGetMalloc(&pShellAllocator);
if (pShellAllocator)
{
char szPath[MAX_PATH + 1];
if (SHGetPathFromIDList(pItemList, szPath))
{
// Chop off the end path seperator
int nPathSize = strlen(szPath);
if (nPathSize > 0)
{
if (szPath[nPathSize - 1] == '\\')
{
szPath[nPathSize - 1] = '\0';
}
}
// Form the file pattern
USES_CONVERSION;
m_sFilePattern.Format(_T("%s\\*.*"), A2T(szPath));
UpdateData(FALSE);
}
pShellAllocator->Free(pItemList);
pShellAllocator->Release();
}
}
}

View File

@ -20,6 +20,9 @@
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxtempl.h>
#include <afxmt.h>
#include <afxpriv.h>
#include <shlobj.h>
// This macro is the same as IMPLEMENT_OLECREATE, except it passes TRUE
// for the bMultiInstance parameter to the COleObjectFactory constructor.