CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: CFileDialog

  1. #1
    Join Date
    May 1999
    Posts
    22

    CFileDialog

    Hi
    I am trying to create an open-file-dialog which only shows the files "*.sv", but my dialog shows all files.
    Hopefully you can help me
    Thanks a lot
    Rene´


    void Telefon::OnImportAdressBook()
    {
    CFileDialog dlg(true);
    static char BASED_CODE szFilter[] = "Text Files (*.sv)|*.sv||";

    dlg.m_ofn.lpstrTitle = "Adressbuch importieren";
    dlg.m_ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY |
    OFN_ENABLEHOOK |OFN_OVERWRITEPROMPT;
    dlg.m_ofn.lpstrFilter = szFilter;
    char buf[256] = "";
    dlg.m_ofn.lpstrFile = buf;


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

    CFile Telefonbuch;
    if(!Telefonbuch.Open(sPath, CFile::modeCreate |
    CFile::modeNoTruncate |
    CFile::modeReadWrite))
    {
    AfxMessageBox("Sorry did not work");
    }
    else
    {
    CArchive ar(&Telefonbuch, CArchive::load);
    Serialize(ar);

    ar.Close();
    }
    Telefonbuch.Close();
    }
    }



  2. #2
    Join Date
    Apr 1999
    Posts
    191

    Re: CFileDialog

    If you want to set lpstrFilter in this manner, I think you need to use '\0' instead of '|'. The '|' character only works in the constructor. Check out the OPENFILENAME struct documentation in the help files.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured