Home > Software engineering >  CFileDialog problem
CFileDialog problem

Time:09-16

1. We need to open the file selection window support fuzzy search, direct use of CFileDialog is the search box, but due to some custom, define a new class, this class inherits from CFileDialog, after the custom template Settings, the search box, no, I don't know if there was any way can make it show up?

2. Because I don't know how to display the search box, I added an edit box to do a fuzzy search, but there is a problem, will be unable to search the results to the CFileDialog own list box, the list box I was obtained through enumeration child controls, to read, remove all have no problem, but no matter like general ListControl, or by sending LVM_ * * series of messages (e.g., LVM_INSERTITEM), can change the display content, such as clear, after all I insert a row I custom data, the results did not show up, the first line shows the original results, personal guess is I actually changed my success, but CFileDialog saved himself a set of data, after I change again after reset again, put my cover?

For a great god, and any comments are appreciated!

CodePudding user response:

//CommonDialog File Open
Void CMyFileOpenDlg: : OnButtonNew ()
{
//TODO: Add your the control notification handler code here
Char fileName [MAX_PATH]="";
CExpFileOpen dlgFile (FALSE);//TRUE);
//CFileDialog dlgFile (TRUE);
//if the use of new style!
OSVERSIONINFO VersionInformation;
GetVersionEx (& amp; VersionInformation);
If (VersionInformation dwMajorVersion & gt;
=5)DlgFile. M_ofn. LStructSize=88;//new=88
The else
DlgFile. M_ofn. LStructSize=76;//old=76
DlgFile. M_ofn. Flags |=OFN_ENABLETEMPLATE;//add our temp!
DlgFile. M_ofn. LpTemplateName=MAKEINTRESOURCE (IDD_EX_OPEN);//=1547!
DlgFile. M_ofn. HInstance=AfxGetInstanceHandle ();
DlgFile. M_ofn. LpstrTitle="Explorer Style Open File".
DlgFile. M_ofn. LpstrFile=fileName;
DlgFile. M_ofn. Flags |=OFN_EXPLORER;
//
DlgFile. M_ofn. LpstrFilter="Any file (*. *) \ 0 *. * \ 0";
DlgFile. M_ofn. LpstrDefExt="TXT";
//dlgFile. M_ofn. LpfnHook=CDN_HookProc;//="_AfxCommDlgProc" see "dlgcomm. CPP" & lt;> NULL!
//show
DlgFile. DoModal ();
# ifdef _DEBUG
//afxDump & lt; # endif
}
Note that
//if the use of new style!

CodePudding user response:

c + + use wildcards for files (FindFirstFile)

  • Related