Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse for files

Status
Not open for further replies.

emperorevil

Programmer
Apr 28, 2002
23
US
How can I, with a dialog box, make a "browse" button that can search for a file of a specific type that can return whatever path was of the file selected?
(I'm new to Visual C++)
 
Try

Add the button to the dialog, and add an event handler using class wizard(or by pressing ctrl and double clicking the button)
and add the following code to the new function

Code:
CString strFilt = "My Files (*.xxx)|.xxx||";
CString myFile = "";

CFileDialog FileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY |
                    OFN_OVERWRITEPROMPT, strFilt);
(if FileDlg.DoModal() == IDOK)
{
  myFile = FileDlg.GetPathName();
}
 
Thanks! Where can I get more information on the "CFileDialog" class?
 
MSDN is fairly helpful - thats where I learnt it from
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top