cfiledialog filedlg(true);
filedlg.m_ofn.lpstrfilter="doc file(*.doc)/0*.doc;*.docx/0all files(*.*)/0*.*/0
/0";
filedlg.domodal();
這三行**就構建了乙個「開啟」檔案對話方塊;
特別需要關注的是檔案的過濾:
msdn如是說:
1、m_ofnis a structure of typeopenfilename;
2、openfilename結構體中有乙個成員項lpstrfilter:
pointer to a buffer containing pairs of null-terminated filter strings.
the last stringin the buffer must be terminated bytwo null characters.
the first stringin each pair is adisplay stringthat describes the filter (for example, "text files"), and the second string specifiesthe filter pattern(for example, "*.txt").
to specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.txt;*.doc;*.bak").
iflpstrfilteris null, the dialog box does not display any filters.
MFC 實現開啟檔案對話方塊 儲存檔案對話方塊
cfiledialog cfiledialog bool bopenfiledialog,lpctstr lpszdefext null,lpctstr lpszfilename null,dword dwflags ofn hidereadonly ofn overwriteprompt,lpct...
開啟對話方塊開啟多個檔案
專案中需要開啟多個檔案,注意的地方1 ofn allowmultiselect 2 m ofn.lpstrfile要分配大點的記憶體 我發現 用ctrl a全選檔案,檔名按從小到大加進去。用shift新增檔案,檔名不是按從小到大加進去的。cstring strfilepath cstring str...
MFC開啟檔案對話方塊
摘自msdn cfiledialog dlgfile true cstring filename const int c cmaxfiles 100 const int c cbbuffsize c cmaxfiles max path 1 1 dlgfile.getofn lpstrfile fi...