Click here to Skip to main content
13,046,679 members (67,533 online)
Rate this:
Please Sign up or sign in to vote.
See more:
How can I access GetpathName in MFCEditBrowse Control.

I want to pass thar pathname to another control.

Thank you.
Posted 18-Mar-13 11:28am
ThePhantomUpvoter 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 18-Mar-13 17:42pm
peoria123 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 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
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:
A standard file selection dialog box is displayed when the user clicks the browse button.

And the latter:
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;
// 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
peoria123 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2017
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