file open dialog when clicking on button 
Author Message
 file open dialog when clicking on button
Hi!
I want to include a file open dialog in an existing MFC-application. It
should appear when clicking on a button. I also need a pointer to the
selected file name.
Thanks for helping, Roland.



Tue, 11 Mar 2003 03:00:00 GMT  
 file open dialog when clicking on button
MFC makes this problem trivial.

CFileDialog dlg(
                 TRUE,
                 "txt",
                 NULL,
                 OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
                 "Text File (*.txt)|*.txt|All Files (*.*)|*.*||"
               );

if (dlg.DoModal() == IDOK)
{
   CString string = dlg.GetPathName();

Quote:
}

Look at the documentation of CFileDialog for the meanings of the
constructor arguments.

--Josh



Quote:
> Hi!
> I want to include a file open dialog in an existing MFC-application.
It
> should appear when clicking on a button. I also need a pointer to the
> selected file name.
> Thanks for helping, Roland.

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 11 Mar 2003 03:00:00 GMT  
 file open dialog when clicking on button

Quote:
>I want to include a file open dialog in an existing MFC-application. It
>should appear when clicking on a button.

Roland,

It's just a matter of using CFileDialog in the button click message
handler. Here's an example I have to hand that uses a Save As dialog:

        char szFileName[_MAX_PATH];
        CFileDialog dlg( false, "lpt", szFileName,
                        OFN_HIDEREADONLY | OFN_NOCHANGEDIR |
                        OFN_NOREADONLYRETURN |
                        OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST );

        if ( dlg.DoModal() == IDOK )
        {
                lstrcpy( szFileName, dlg.GetPathName() );

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Tue, 11 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. File Open Dialog - Open button Enable&Disable

2. File Open Dialog - Open button Enable&Disable

3. File Open Dialog - Open button Enable&disable

4. Double Click Problem in File Open Dialog

5. Click 1 button = click 2 button?

6. How can I open the File Open system dialog box by clicking another menu item than File/Open?

7. Opening files by double clicking in File Manager.

8. HOW TO Filter Files Without File Extention in Open File Dialog Box

9. File extension filtering for the file dialog presented for file opening

10. Radio button click event being sent when Dialog gains focus

11. Please help on how to show a help window on clicking a dialog button

12. Dialog buttons get ugly black borders once clicked ?

 

 
Powered by phpBB® Forum Software