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

hongrong 2004-12-10 11:37:54
如何在文件菜单中保存和打开菜单命令中添加.cpp和.doc扩展名,如保存时用.cpp扩展名。
...全文
201 8 打赏 收藏 转发到动态 举报
写回复
用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);
vc6.0 使用教程详解.doc,大小仅 284KB,但作为一个 vc6.0 的入门教程,本书就足够了。 内容预览: 你首先要打开VC6.0界面,一般用得较多的是Win32控制台应用程序(源程序,扩展名.cpp), 步骤是:(先工程—后文件—编译—连接---运行) 1,建立一个工程,“文件”——“新建”,出现下面界面: 选择“Win32 Console Application”(控制台应用程序,左边倒数第三个),命名工程名称,选择保存位置, 点击“确定”,进入下一步,看到如下提示界面: 建立一个空工程,对应其他需要的你一可以建立别的工程;点击“完成”,之后: 显示你创建的工程的信息。 2,再在有一个的工程的条件下,我们再建立一个源文件; “文件”——“新建”(快捷键Ctri+N),出现: 建立源文件,选择“C++ Source ”,一般都是建立这种文件的(适用在当文件适用)如果要建立头文件的话,选择“C/C++ Header File”,(适用在多文件工程使用)命名,文件名称,点击“确定”,之后: 进入编辑区,在主界面编写代码:如下编写完之后呢: 可以按编译按钮 调试程序,看看有没有错误,有的话改正,没有的话就可以再按连接按钮 检查连接(多文件工程时常用,检查文件间是否正常连接),最后,点运行按钮 ,就可以运行了。 如果是您有代码如:cpp文件,或 .h 文件,想添加都VC6.0里来测试的话,可以这样做: 首先,要理解一下 文件扩展名为:cpp和.h 文件扩张名是.h,代表的是头文件,一般是书写一些函数原型,以及一些在整个程序常用到的结构体,频繁使用的函数说明,定义等等; 文件扩张名为,cpp的,是C++的源文件,也是最常用到的文件,每建立一个工程都要至少一个源文件(至少要有一个函数入口——主函数main() ),包含了核心代码; 建立与运行说明:(以VC 6.0编译器为例,其他编译器类似) 首先,打开VC 6.0编译环境; 在菜单栏——文件(的下拉菜单选择“新建”),在弹出的选择窗口,选Win32 Console Application(控制台应用程序) ,在填写工程名称,选择一个程序保存路径,点击“完成”,查看工程信息。在点击“确定”,就建立一个简单的工程了。 再点击左边的工程信息右下角的“FileView”选项;可以看到你新建的工程,再双击你新建的工程名 可以查看工程的信息。 在双击工程文件,在这里是 777.files,可以看到该工程的包含的文件 其,Source Files 为包含所有工程的源文件 Header Files 为包含所有工程的头文件 在源文件选项“Source Files ”,右键单击的“添加目录到工程”,添加你要打开扩展名为 .cpp的源文件。在头文件选项“ Header Files”,右键单击的“添加目录到工程”,添加你要打开扩展名为 . h的头文件。添加完你所有的头文件和源文件之后,检查一下是否添加完毕,之后就可以编译了。 其第一个按钮 为编译按钮,可以找出工程的错误信息,有错误修改,没错误就可以跳到连接 ,编译右边的按钮 ,即第三个按钮(多文件工程一定要连接,查看文件是否准确相连接) 当编译,连接都没有错误时,可以按运行按钮 ,即可以运行了。

16,550

社区成员

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

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

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