1. 如何改“打开”,“另存为” 那个对话框的标题?
2. 我在保存的时候,可能会有多种文件格式,如:
static char BASED_CODE szFilter[] =
"Iges Files (*.igs;*.iges)|*.igs; *.iges|STEP Files (*.stp;*.step)|*.stp; *step||";
我先用了
CString exportFileName;
if(m_currentFileShortName.GetLength() != 0)
{
int ipos = m_currentFileShortName.ReverseFind('.');
exportFileName = m_currentFileShortName.Left(ipos);
}
得到当前文档类处理的文件名,不含路径及扩展名
下面我想让它在“另存为”的对话框里显示为:
当我选择(也是默认选择)Iges Files (*.igs;*.iges)时,显示aa.igs,
当我切换到STEP Files (*.stp;*.step)时自动变化到aa.stp
这个如何实现。
2. 我在保存的时候,可能会有多种文件格式,如:
static char BASED_CODE szFilter[] =
"Iges Files (*.igs;*.iges)|*.igs; *.iges|STEP Files (*.stp;*.step)|*.stp; *step||";
我先用了
CString exportFileName;
if(m_currentFileShortName.GetLength() != 0)
{
int ipos = m_currentFileShortName.ReverseFind('.');
exportFileName = m_currentFileShortName.Left(ipos);
}
得到当前文档类处理的文件名,不含路径及扩展名
下面我想让它在“另存为”的对话框里显示为:
当我选择(也是默认选择)Iges Files (*.igs;*.iges)时,显示aa.igs,
当我切换到STEP Files (*.stp;*.step)时自动变化到aa.stp
这个如何实现。
解决方案 »
- 内存映射文件的问题。。
- 一个语法问题
- 如何屏蔽键盘上的ATL+CTRL+DEL的组合键功能?
- 巨困难的问题:CTreeCtrl和CListCtrl,被滚动条拖动后,如何取得左侧和上侧被隐藏区域的尺寸
- 如何在VC中使用DB-LIBRARY的方式调用SQL SERVER 数据库中的在存储过程!
- 怎样建一个与主对话框同时出现的子窗口
- 谁有浮雕的源程序和算法原理!!!!急用!!!
- 什么的办法将 SDI/MDI 程序的"最大化""最小化""关闭"的按钮去掉?
- 制作获取部分视频数据能够播放的播放器
- 截图工具如何截取指针。。
- windows 桌面左下角的”开始“实现上拉菜单是如何实现的?
- 这段代码有没有问题?
~~~~
void CSiFangView::OnFileSave()
{
CSaveDlg dlg(
FALSE, //TRUE=File Open, FALSE=File Save As
_T(".doc"), //default filename extension
"", //initial filename in edit box
// functionality flags
// OFN_ALLOWMULTISELECT| //allow multiple files to be selected
// OFN_CREATEPROMPT | // if File Save As, prompts user if they want to create non-existant file
OFN_OVERWRITEPROMPT | // if File Save As--prompts user to ask if they want to overwrite an existing file
// OFN_ENABLESIZING | // if Windows NT 5.0 or Win 98, causes box to be resizable by user
OFN_EXTENSIONDIFFERENT| // allows user to enter a filename with a different extension from the default
// OFN_FILEMUSTEXIST // file must exist
// OFN_NOLONGNAMES | // causes dialog to use short filenames (8.3)
// OFN_PATHMUSTEXIST | // user can only type valid paths and filenames
// OFN_NOVALIDATE | // the returned filname can have invalid characters
// appearence flags
OFN_HIDEREADONLY | // hides read-only check box
// OFN_NONETWORKBUTTON | // hides Network button
// OFN_READONLY | // initially check Read Only check box
// OFN_SHOWHELP | // Help button appears--when clicked the hook procedure gets a CDN_HELP message
// custom template flags
OFN_ENABLETEMPLATE | // you will be supplying your own custom dialog box template
0,
szFilter, //file filter
NULL); // parent window // set an initial directory
dlg.m_ofn.lpstrInitialDir = m_sInitDirData; //set the dialog's title
char lpszTitle[]={"保存参数数据"};
dlg.m_ofn.lpstrTitle=lpszTitle; // retain the customer's last file filter selection
dlg.m_ofn.nMaxCustFilter=255; // if OFN_ENABLETEMPLATE is set, define the custom dialog template here
dlg.m_ofn.lpTemplateName=MAKEINTRESOURCE(IDD_SAVE_DLG);//IDD_WZD_FILEOPEN);
{
OPENFILENAME ofn ;
TCHAR szFullName[_MAX_PATH];
::ZeroMemory (&ofn, sizeof(OPENFILENAME)) ;
szFullName[0] = TEXT('\0') ;
ofn.lStructSize = sizeof (OPENFILENAME) ;
ofn.hwndOwner = m_hWnd;
ofn.hInstance = NULL ;
ofn.lpstrFilter = "exe 文件\0;*.EXE\0";
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 0 ;
ofn.nMaxFile = MAX_PATH ;
ofn.nMaxFileTitle = MAX_PATH ;
ofn.lpstrInitialDir = "c:\\" ;
ofn.lpstrTitle = "保存到";
ofn.lpstrFile = szFullName ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = TEXT("exe") ;
ofn.lCustData = 0 ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;
ofn.Flags = OFN_ENABLESIZING | OFN_OVERWRITEPROMPT ;
if(!GetOpenFileName(&ofn))
return "";
else
return ofn.lpstrFile;
}
{
OPENFILENAME ofn ;
TCHAR szFullName[_MAX_PATH];
::ZeroMemory (&ofn, sizeof(OPENFILENAME)) ;
szFullName[0] = TEXT('\0') ;
ofn.lStructSize = sizeof (OPENFILENAME) ;
ofn.hwndOwner = m_hWnd;
ofn.hInstance = NULL ;
ofn.lpstrFilter = "exe 文件\0;*.EXE\0";
ofn.lpstrCustomFilter = NULL ;
ofn.nMaxCustFilter = 0 ;
ofn.nFilterIndex = 0 ;
ofn.nMaxFile = MAX_PATH ;
ofn.nMaxFileTitle = MAX_PATH ;
ofn.lpstrInitialDir = "c:\\" ;
ofn.lpstrTitle = "保存到";
ofn.lpstrFile = szFullName ;
ofn.nFileExtension = 0 ;
ofn.lpstrDefExt = TEXT("exe") ;
ofn.lCustData = 0 ;
ofn.lpfnHook = NULL ;
ofn.lpTemplateName = NULL ;
ofn.Flags = OFN_ENABLESIZING | OFN_OVERWRITEPROMPT ;
if(!GetOpenFileName(&ofn))
return "";
else
return ofn.lpstrFile;
}
另存为对话框有
文件名:编辑框
文件类型:这是一个下拉框,可选保存为若干种文件格式。我的问题是:让当前的文件在文件名的编辑框里以文件类型的扩展名形式显示,如aa.igs
当切换到下一种类型时,它就变成aa.stp,以此类推。要求在文件名编辑框里就可以显示带扩展名的文件名,而且随类型切换而变化。可以参照ACDSee的“另存为”这下说明白了吗?
CFileDialog Overview | Class Members | Hierarchy Chart | CFileDialog::OnFileChange
Override this function to handle the WM_NOTIFY CDN_TYPECHANGE messagesend CDM_SETCONTROLTEXT to the dialog.Command what is yours
Conquer what is not