1. 現需要打開檔案選擇窗時支持模糊搜索,直接使用CFileDialog是有這個搜索框的,但是由于有一些定制,定義了一個新的類,這個類繼承自CFileDialog,設定過自定義模板之后,這個搜索框就沒有了,不知道是否有什么方法可使它顯示出來 ?
2. 因為不知道如何將搜索框顯示出來,我自己添加了一個編輯框來做模糊搜索,但是有個問題,無法將搜索出來的結果顯示到CFileDialog自帶的串列框。這個串列框我是通過列舉子控制元件獲取到的,讀取、清除項都沒有問題,但是不論像一般的ListControl,或者通過發送LVM_** 系列訊息(如LVM_INSERTITEM),都無法更改其顯示的內容,比如我全部清除之后,插入一行我自定義的資料 ,結果并沒有顯示出來,顯示的是原結果的第一行。個人猜測會不會是我其實改成功了,但CFileDialog自己存了一套資料,在我改完之后又重設了一遍,把我的覆寫了?
求教各位大神,任何意見都感激不盡!
uj5u.com熱心網友回復:
// CommonDialog File Openvoid CMyFileOpenDlg::OnButtonNew()
{
// TODO: Add your control notification handler code here
char fileName[MAX_PATH]="";
CExpFileOpen dlgFile(FALSE);//TRUE);
// CFileDialog dlgFile(TRUE);
//if use new style!
OSVERSIONINFO VersionInformation;
GetVersionEx(&VersionInformation);
if(VersionInformation.dwMajorVersion >= 5)
dlgFile.m_ofn.lStructSize=88;// new =88
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" <>NULL!
// show
dlgFile.DoModal();
#ifdef _DEBUG
// afxDump << fileName << " \n";
#endif
}
注意
//if use new style!
uj5u.com熱心網友回復:
C++使用通配符查找檔案(FindFirstFile)轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/40505.html
標籤:界面
