• 全部
  • VC综合技术
  • 互联网技术
  • MFC AppLauncher
  • .NET 技术
  • 界面
  • 进程
  • 算法
  • 硬件/系统
  • 数据库
  • VC++技术资源

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

hongrong 2004-12-10 11:37:54
如何在文件菜单中保存和打开菜单命令中添加.cpp和.doc扩展名,如保存时用.cpp扩展名。
...全文
131 点赞 收藏 8
写回复
8 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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);
回复
相关推荐
发帖
VC/MFC
创建于2007-09-28

1.5w+

社区成员

VC/MFC相关问题讨论
申请成为版主
帖子事件
创建了帖子
2004-12-10 11:37
社区公告

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