bool WDL_ChooseDirectory(HWND parent, const char *text, const char *initialdir, char *fn, int fnsize, bool preservecwd) { char olddir[2048]; GetCurrentDirectory(sizeof(olddir),olddir); #ifdef _WIN32 char name[4096]; lstrcpyn(name,initialdir?initialdir:"",sizeof(name)); BROWSEINFO bi={parent,NULL, name, text, BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE, WDL_BrowseCallbackProc, (LPARAM)name,}; LPITEMIDLIST idlist = SHBrowseForFolder( &bi ); if (idlist) { SHGetPathFromIDList( idlist, name ); IMalloc *m; SHGetMalloc(&m); m->Free(idlist); lstrcpyn(fn,name,fnsize); return true; } return false; #else bool r = BrowseForDirectory(text,initialdir,fn,fnsize); if (preservecwd) SetCurrentDirectory(olddir); return r; #endif }
static void Directories_OnBrowse(HWND hDlg) { int nType; int nItem; TCHAR inbuf[MAX_PATH]; TCHAR outbuf[MAX_PATH]; HWND hList; hList = GetDlgItem(hDlg, IDC_DIR_LIST); nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (nItem == -1) return; nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)); if (IsMultiDir(nType)) { /* Last item is placeholder for append */ if (nItem == ListView_GetItemCount(hList) - 1) { Directories_OnInsert(hDlg); return; } } ListView_GetItemText(hList, nItem, 0, inbuf, MAX_PATH); if (BrowseForDirectory(hDlg, inbuf, outbuf) == TRUE) { nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)); DirInfo_SetDir(g_pDirInfo, nType, nItem, outbuf); UpdateDirectoryList(hDlg); } }
void GrooveDialog::OnGrooveFolderButton(WORD wParam, LPARAM lParam) { if (wParam != BN_CLICKED) return; char cDir[256]; GrooveTemplateHandler *me = GrooveTemplateHandler::Instance(); if (BrowseForDirectory(__LOCALIZE("Select folder containing grooves","sws_DLG_157"), me->GetGrooveDir().c_str(), cDir, 256)) { currentDir = cDir; me->SetGrooveDir(currentDir); RefreshGrooveList(); } }
static void Directories_OnInsert(HWND hDlg) { int nItem; char buf[MAX_PATH]; HWND hList; hList = GetDlgItem(hDlg, IDC_DIR_LIST); nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (BrowseForDirectory(hDlg, NULL, buf) == TRUE) { int i; int nType; /* list was empty */ if (nItem == -1) nItem = 0; nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)); switch (nType) { case ROM: case SAMPLE: if (MAX_DIRS <= DirInfo_NumDir(pDirInfo, nType)) return; for (i = DirInfo_NumDir(pDirInfo, nType); nItem < i; i--) strcpy(DirInfo_Path(pDirInfo, nType, i), DirInfo_Path(pDirInfo, nType, i - 1)); strcpy(DirInfo_Path(pDirInfo, nType, nItem), buf); DirInfo_NumDir(pDirInfo, nType)++; pDirInfo->m_Paths[nType].m_bModified = TRUE; break; } UpdateDirectoryList(hDlg); ListView_SetItemState(hList, nItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); } }
static BOOL SoftwareDirectories_OnInsertBrowse(HWND hDlg, BOOL bBrowse, LPCTSTR lpItem) { int nItem; TCHAR inbuf[MAX_PATH]; TCHAR outbuf[MAX_PATH]; HWND hList; LPTSTR lpIn; BOOL res; g_bModifiedSoftwarePaths = TRUE; hList = GetDlgItem(hDlg, IDC_DIR_LIST); nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (nItem == -1) return FALSE; /* Last item is placeholder for append */ if (nItem == ListView_GetItemCount(hList) - 1) { bBrowse = FALSE; } if (!lpItem) { if (bBrowse) { ListView_GetItemText(hList, nItem, 0, inbuf, ARRAY_LENGTH(inbuf)); lpIn = inbuf; } else { lpIn = NULL; } if (!BrowseForDirectory(hDlg, lpIn, outbuf)) return FALSE; lpItem = outbuf; } AppendList(hList, lpItem, nItem); if (bBrowse) res = ListView_DeleteItem(hList, nItem+1); MarkChanged(hDlg); return TRUE; }
static void Directories_OnInsert(HWND hDlg) { int nItem; TCHAR buf[MAX_PATH]; HWND hList; hList = GetDlgItem(hDlg, IDC_DIR_LIST); nItem = ListView_GetNextItem(hList, -1, LVNI_SELECTED); if (BrowseForDirectory(hDlg, NULL, buf) == TRUE) { int i; int nType; /* list was empty */ if (nItem == -1) nItem = 0; nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO)); if (IsMultiDir(nType)) { if (MAX_DIRS <= DirInfo_NumDir(g_pDirInfo, nType)) return; for (i = DirInfo_NumDir(g_pDirInfo, nType); nItem < i; i--) _tcscpy(DirInfo_Path(g_pDirInfo, nType, i), DirInfo_Path(g_pDirInfo, nType, i - 1)); _tcscpy(DirInfo_Path(g_pDirInfo, nType, nItem), buf); DirInfo_NumDir(g_pDirInfo, nType)++; DirInfo_SetModified(g_pDirInfo, nType, TRUE); } UpdateDirectoryList(hDlg); ListView_SetItemState(hList, nItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); } }
static int OnBrowseDirClick(HWND hDlg) { return BrowseForDirectory(hDlg, MAKEINTRESOURCE(IDC_DIRECTORY_NAME), IDS_SELECT_DIRECTORY); }
static int OnBrowseDirClick(HWND hDlg) { BrowseForDirectory(hDlg, MAKEINTRESOURCE(IDC_DIRECTORY_NAME), IDS_SELECT_DIRECTORY, MAX_PATH); ConvertToNtName(hDlg, IDC_DIRECTORY_NAME); return TRUE; }