如何在保存和打开菜单命令中添加.cpp和.doc扩展名

hongrong 2004-12-10 11:37:54
如何在文件菜单中保存和打开菜单命令中添加.cpp和.doc扩展名,如保存时用.cpp扩展名。
...全文
174 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hongrong 2004-12-13
  • 打赏
  • 举报
回复
up
EnochShen 2004-12-10
  • 打赏
  • 举报
回复
IDR_MAINFRAME
YourApp\n\n\ncpp(*.cpp);\n.cpp\nYour.Document\nYour
EnochShen 2004-12-10
  • 打赏
  • 举报
回复
IDR_MAINFRAME
YourApp\n\n\ncpp(*.mdb);\n.cpp\nYour.Document\nYour
老夏Max 2004-12-10
  • 打赏
  • 举报
回复
或者重载那两个函数自己写!
参考:
void CMyPlayerDlg::OnButtonOpen()
{
// TODO: Add your control notification handler code here
CString strFilter = "Mp3 File(*.mp3)|*.mp3|";
strFilter += "MPEG File(*.mpg;*.mpeg)|*.mpg;*.mpeg|";
strFilter += "Wave File(*.wav)|*.wav|";
strFilter += "AVI File(*.avi)|*.avi|";
strFilter += "All File(*.*)|*.*|";
CFileDialog dlgOpen(TRUE,NULL,NULL,OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,strFilter,this);
DWORD MAXFILE = 2412; // allocate enough memory space
dlgOpen.m_ofn.nMaxFile = MAXFILE; // set the buffer size
CString strFileName;
char* buf = new char[MAXFILE];
dlgOpen.m_ofn.lpstrFile = buf;
dlgOpen.m_ofn.lpstrFile[0] = NULL;
if(IDOK == dlgOpen.DoModal())
{
POSITION pos = dlgOpen.GetStartPosition();
while (pos != NULL)
{
strFileName = dlgOpen.GetNextPathName(pos);
// get the individual file name
m_SourceFileList.InsertString(m_SourceFileList.GetCount(),strFileName);// add to Mp3 ListBox
}
}
delete [] buf;
}
老夏Max 2004-12-10
  • 打赏
  • 举报
回复
CDocTemplate::GetDocString
virtual BOOL GetDocString( CString& rString, enum DocStringIndex index ) const;

Return Value

Nonzero if the specified substring was found; otherwise 0.

Parameters

rString

A reference to a CString object that will contain the string when the function returns.

index

An index of the substring being retrieved from the string that describes the document type. This parameter can have one of the following values:

CDocTemplate::windowTitle Name that appears in the application window’s title bar (for example, “Microsoft Excel”). Present only in the document template for SDI applications.


CDocTemplate::docName Root for the default document name (for example, “Sheet”). This root, plus a number, is used for the default name of a new document of this type whenever the user chooses the New command from the File menu (for example, “Sheet1” or “Sheet2”). If not specified, “Untitled” is used as the default.


CDocTemplate::fileNewName Name of this document type. If the application supports more than one type of document, this string is displayed in the File New dialog box (for example, “Worksheet”). If not specified, the document type is inaccessible using the File New command.


CDocTemplate::filterName Description of the document type and a wildcard filter matching documents of this type. This string is displayed in the List Files Of Type drop-down list in the File Open dialog box (for example, “Worksheets (*.xls)”). If not specified, the document type is inaccessible using the File Open command.


CDocTemplate::filterExt Extension for documents of this type (for example, “.xls”). If not specified, the document type is inaccessible using the File Open command.


CDocTemplate::regFileTypeId Identifier for the document type to be stored in the registration database maintained by Windows. This string is for internal use only (for example, “ExcelWorksheet”). If not specified, the document type cannot be registered with the Windows File Manager.


CDocTemplate::regFileTypeName Name of the document type to be stored in the registration database. This string may be displayed in dialog boxes of applications that access the registration database (for example, “Microsoft Excel Worksheet”).
Remarks

tigerjacky 2004-12-10
  • 打赏
  • 举报
回复
CString szFilter ;
szFilter = "CPP文件(*.cpp)|*.cpp|所有文件 (*.*)|*.*||";
CFileDialog dlg(FALSE, "CPP文件", "*.cpp", OFN_HIDEREADONLY , szFilter );
dlg.m_ofn.lpstrInitialDir = ::G_Get2Dir(* sOPath);
if (dlg.DoModal() == IDOK)
{
* sOPath = dlg.GetPathName();//full file path
}
老夏Max 2004-12-10
  • 打赏
  • 举报
回复
编辑字符串资源即可。
koko1998 2004-12-10
  • 打赏
  • 举报
回复
//open
CString strSel = _T("csvFiles(*.csv)|*.csv||");
CFileDialog dlg(TRUE,_T("*.csv"),_T("*.csv"),
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,strSel);

//save
wchar_t szFilters[]= _T("File Out Files (*.csv)|*.csv||");
CFileDialog fileDlg (FALSE, _T("*.csv"),_T("*.csv"),
OFN_PATHMUSTEXIST|OFN_OVERWRITEPROMPT, szFilters, this);

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧