1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| bool GetFolder(TCHAR *folderpath, UINT flag=BIF_USENEWUI,const TCHAR* szCaption = NULL,TCHAR *initial=NULL, HWND hOwner = NULL)
{
bool retVal = false;
// The BROWSEINFO struct tells the shell
// how it should display the dialog.
BROWSEINFO bi;
memset(&bi, 0, sizeof(bi));
bi.ulFlags = flag;
bi.hwndOwner = hOwner;
bi.lpszTitle = szCaption;
/*bi.lpfn=BrowseCallbackProc;
bi.lParam=(LPARAM)initial;*/
// must call this if using BIF_USENEWUI
//::OleInitialize(NULL);
// Show the dialog and get the itemIDList for the selected folder.
LPITEMIDLIST pIDL = ::SHBrowseForFolder(&bi);
if(pIDL != NULL)
{
// Create a buffer to store the path, then get the path.
TCHAR buffer[_MAX_PATH] = {'\0'};
if(::SHGetPathFromIDList(pIDL, buffer) != 0)
{
_tcscpy(folderpath,buffer);
// Set the string value.
// folderpath = buffer;
retVal = true;
}
// free the item id list
CoTaskMemFree(pIDL);
}
//::OleUninitialize();
return retVal;
}
int int_ad_purges()
{
TCHAR dir[MAX_PATH];
HWND hwnd;
CMDIFrameWnd *cfw=acedGetAcadFrame();
hwnd=cfw->GetSafeHwnd();
if (!GetFolder(dir,64|16,_T("Selectionner répertoire contenant les DWG"),0,hwnd))
return RSRSLT;
return RSRSLT;
} |
Partager