CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Shortcut files not filter from CFileDialog?

    Hi all,

    i m Using CFileDialog with filter or text file to browse only *.txt files.

    but shortcut files are also visible in open file dialog .

    please tell me how can i resolve this.

    thanks in advance.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Shortcut files not filter from CFileDialog?

    Shortcut files to .txt files? Or what kind of shortcut files do you see?
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    May 2004
    Location
    45,000FT Above Nevada
    Posts
    1,539

    Re: Shortcut files not filter from CFileDialog?

    Quote Originally Posted by vjshankwar View Post
    Hi all,

    i m Using CFileDialog with filter or text file to browse only *.txt files.

    but shortcut files are also visible in open file dialog .

    please tell me how can i resolve this.

    thanks in advance.
    Please show the code you are using to filter files...no mind readers here.
    Jim
    ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII

    "The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.

    "Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.

  4. #4
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: Shortcut files not filter from CFileDialog?

    Code:
    CString filter=_T("Text Files(*.txt)|*.txt||");
    
    	CFileDialog fileDlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST,filter);
    
    
    	if (fileDlg.DoModal () == IDCANCEL) 
    	{
    		return;
    	}
    	CString file_Path = fileDlg.GetPathName ();
    	AfxMessageBox(file_Path);
    i locate a folder by CFileDialog here text files are present and some shortcut of .docx and .xlsx are also presents to these are displayed.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Shortcut files not filter from CFileDialog?

    Your code seems to work fine. I tested it on Win7 with VC++ 2010.

    Code:
    //	CString sFilter( _T("Text Files(*.txt)|*.txt|All Files(*.*)|*.*||" ) );
    	CString sFilter( _T("Text Files(*.txt)|*.txt||" ) );
    
    	static TCHAR szFilter[] = _T("Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||");
    
    
    	CFileDialog fileDlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST,sFilter);
    
    
    	if (fileDlg.DoModal () == IDCANCEL) 
    	{
    		return;
    	}
    	CString file_Path = fileDlg.GetPathName ();

  6. #6
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Shortcut files not filter from CFileDialog?

    see the code works fine for me too on windows xp with vs 2005.

    if you mentioning that folder shortcuts and folder are viewable while only .txt is selected then it cant be done as it by default windows style. *.txt will filter only the files. not folders.
    ◄◄ hypheni ►►

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