Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++
How can I access GetpathName in MFCEditBrowse Control.
 
I want to pass thar pathname to another control.
 
Thank you.
Posted 18-Mar-13 12:28pm
Comments
ThePhantomUpvoter at 18-Mar-13 17:35pm
   
Where did you get this MFCEditBrowse control from? GetPathName belongs to CFileDialog. Maybe you should go ahead and post some code or more clearly explain what it is that you are trying to do.
Sergey Alexandrovich Kryukov at 18-Mar-13 17:42pm
   
Right.
peoria123 at 18-Mar-13 17:55pm
   
yeah it doesn't have GetFilepath..I have used MFCEDITBrowse controls on my dialog.. with that i can browse the file and editbox of browsecontrol shows that selected filepath. I want to store that filepath into any variable or string to pass to another control.(how I can get selected path from editbox of browse control?)
Thank you.
ThePhantomUpvoter at 18-Mar-13 18:06pm
   
I would suggest that you consult the documentation for the MFCEditBrowse control you say you are using and see if it has some method available. You might try asking the vendor for the control. Failing that, you could try GetWindowText.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

When you use CMFCEditBrowseCtrl[^] class you get the selected path the same way you do with a normal edit control. I.e. you use GetWindowText() method.
 
As you know, the control can be created with three modes: file mode, folder mode and custom mode. Let's put the custom mode aside and check file and folder modes. The former, according to MSDN:
Quote:
A standard file selection dialog box is displayed when the user clicks the browse button.

 
And the latter:
Quote:
A standard folder selection dialog box is displayed when the user clicks the browse button.

 
So, as you see you can use the control for both Folders and Files.
 
You've asked how to get the path name. I assume you used your control in file mode and now want to strip the file part and get only the path part. You do this using PathRemoveFileSpec [^] function. Here is a small example:
 
CString strText;
m_edFile.GetWindowText(strText);
// strText now contains the full path of the selected file, i.e. c:\Temp\report.txt

::PathRemoveFileSpec(CStrBuf(strText, MAX_PATH));
// strText now contains the path of the selected file, i.e. c:\Temp\
 
You can check my article Image Cataloguer[^], where I use the new controls from the MFC Feature pack
  Permalink  
Comments
peoria123 at 19-Mar-13 12:43pm
   
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 205
1 Richard MacCutchan 185
2 DamithSL 170
3 Tomas Takac 146
4 OriginalGriff 132
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100