how to select a required directory
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
BOOL CCreateDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_Enter_Location = "C:\\DS\\Index\\"; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
Have a look at
SHBrowseForFolder()
instead. It's specifically designed for allowing the user to choose folders rather than files.CFileDialog
designed for choosing files, not folders.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
Hi keerthikaaa, maybe it is some helpful to you CFileDialog m_dlg(1); m_dlg.DoModal(); GetDlgItem(IDC_EDIT1)->SetWindowText(m_dlg.GetPathName()); -- modified at 2:35 Tuesday 11th April, 2006 BROWSEINFO bi; TCHAR m_DisplayName[MAX_PATH]; m_DisplayName[0]='\0'; memset(&bi, 0x00, sizeof(bi)); bi.hwndOwner = this->m_hWnd; bi.pszDisplayName = m_DisplayName; bi.ulFlags = BIF_EDITBOX; LPITEMIDLIST pidl = SHBrowseForFolder(&bi); if (pidl) SHGetPathFromIDList(pidl, m_DisplayName); GetDlgItem(IDC_EDIT1)->SetWindowText(m_DisplayName);
-
BOOL CCreateDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_Enter_Location = "C:\\DS\\Index\\"; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
Hi parichaybp, Can you be more specific
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
I recomend you to use Davide Calabro's CFileDialogST[^] - very good for folder selection!
-
hai to all i would like to know how can we select a particular directory by using the CFileDialog . And display the selected directory in a static text or edit box. :)
hai to all i have written the code like this for getting a directory selcted and display the path of the selected directory. i was able to select the directory but it is not opening the directory. And the path is not displayed in the edit box which i have specified. here it is: static char BASED_CODE szFilter[] = "Directory Files (*.dir) | *.dir ||"; //create the file open dialog CFileDialog m_ldFile(TRUE, ".dir",m_sResults,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter); //Show the file open dialog and capture result if(m_ldFile.DoModal()==IDOK) { m_sResults=m_ldFile.GetFolderPath(); //Update the Dialog UpdateData(FALSE); } so anyone of u help to get out of this. :)
-
hai to all i have written the code like this for getting a directory selcted and display the path of the selected directory. i was able to select the directory but it is not opening the directory. And the path is not displayed in the edit box which i have specified. here it is: static char BASED_CODE szFilter[] = "Directory Files (*.dir) | *.dir ||"; //create the file open dialog CFileDialog m_ldFile(TRUE, ".dir",m_sResults,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter); //Show the file open dialog and capture result if(m_ldFile.DoModal()==IDOK) { m_sResults=m_ldFile.GetFolderPath(); //Update the Dialog UpdateData(FALSE); } so anyone of u help to get out of this. :)
keerthikaaa wrote:
static char BASED_CODE szFilter[] = "Directory Files (*.dir) | *.dir ||"
Have you got a special file type that has a ".dir" extension? File-system directories don't end in ".dir" normally. By specifying this filter, you'll only allow files that end in ".dir" to be shown in the list control.
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Hi keerthikaaa, maybe it is some helpful to you CFileDialog m_dlg(1); m_dlg.DoModal(); GetDlgItem(IDC_EDIT1)->SetWindowText(m_dlg.GetPathName()); -- modified at 2:35 Tuesday 11th April, 2006 BROWSEINFO bi; TCHAR m_DisplayName[MAX_PATH]; m_DisplayName[0]='\0'; memset(&bi, 0x00, sizeof(bi)); bi.hwndOwner = this->m_hWnd; bi.pszDisplayName = m_DisplayName; bi.ulFlags = BIF_EDITBOX; LPITEMIDLIST pidl = SHBrowseForFolder(&bi); if (pidl) SHGetPathFromIDList(pidl, m_DisplayName); GetDlgItem(IDC_EDIT1)->SetWindowText(m_DisplayName);
hai whitesky thanks for ur help i got it :)