title: MFC CFileDialog open only select files
body: <p>Using CFileDialog as a file open, I need to allow the user to only select a file that is displayed in the dialog list area, such as by clicking on it. We don't want the user to be able to type in a name in the File Name control. The OPENFILENAME (OFN) struct has several different flags (<a href="http://msdn.microsoft.com/en-US/library/ms646839%28v=vs.80%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-US/library/ms646839%28v=vs.80%29.aspx</a>), but I don't see one that prevents the user from typing in a filename.</p>
  
  <p>The closest thing I saw was OFN_FILEMUSTEXIST, but that only specifies that the file exists; it still allows the user to type in a name.</p>
  
  <p>Is there any way to do this without inheriting a new class?</p>
  
  <p><strong>MORE INFO</strong></p>
  
  <p>We need to prevent them from typing in a filename because they could open an inappropriate one. With the <code>lpszFilter</code> parameter, we filter the filenames so it only displays files with <em>ABC</em> in the filename (not the extension). So if they typed in a filename, they could enter something like <code>myCoolFileDEF.ext</code>. If the file exists, it will go ahead and let them open it (the dialog will close w/o an error message) even though they were only supposed to open files with <em>ABC</em> in the filename.</p>