how to show browse button?
-
i want to show browse button on a dialog box application and i want to select a folder not file. how can i implement for browse control for selecting folder? thanks in advance.
You can use of
SHBrowseForFolder
. -
You can use of
SHBrowseForFolder
. -
thanks Hamid for replying me. Could u plz tell me whether i can get some sample code or sample project for browse control?
-
hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?
-
hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?
Why you dont use of SHBrowseForFolder it simple to use.
-
Why you dont use of SHBrowseForFolder it simple to use.
-
hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?
I hope this little sample code will help you if you want to select the folder, void CFolderSelectionDlg::OnBrowseClick() { BROWSEINFO brwsInfo; ZeroMemory(&brwsInfo,sizeof(BROWSEINFO)); int iImage = 0; char szFolderPath[MAX_PATH]; char szTitle[255]; memset(szFolderPath,'\0',sizeof(szFolderPath)); memset(szTitle,'\0',sizeof(szTitle)); brwsInfo.hwndOwner = GetSafeHwnd(); brwsInfo.iImage = iImage; brwsInfo.lpfn = NULL; brwsInfo.pidlRoot = NULL; brwsInfo.pszDisplayName = szFolderPath; brwsInfo.lpszTitle = szTitle; //InitCommonControls(); ITEMIDLIST *ptrItemList = SHBrowseForFolder(&brwsInfo); if(ptrItemList != NULL) m_strFolderPath = szFolderPath; UpdateData(FALSE); } this is the simplest. if you want all advanced functionality, you should inherit yoour custom fileDialog class. please go thourh the MSDN.you have to write your version of virtual void OnFolderChange(); virtual BOOL OnFileNameOK(); best of luck...
kamalesh
-
hi Hamid, thanks a lot for replying me. i want to make implementation simple so what i have done is: i have taken 1 button, on click event i have implemented as below: void Logfilepath::OnBrowse() { // TODO: Add your control notification handler code here { CFileDialog FileDialog(TRUE,"*.*",NULL,OFN_HIDEREADONLY,"Text Files: (*.txt)|*.txt||",this); if(FileDialog.DoModal() == IDOK) { CString PathName = FileDialog.GetPathName(); // CString PathName1 =FileDialog.GetFolderPath(); m_ctrledit.SetWindowText(PathName); } } } now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?
Anjali Patil wrote:
now with this implementation i am able to select files but i want to select only folder. what other implementation i should do so that i will be able to select folder and not file?
You were suggested to use
SHBrowseForFolder()
. Why show code that does otherwise? :confused:"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch