cfiledialog

CFileDialog truncates offered file name

雨燕双飞 提交于 2021-01-27 18:30:01
问题 I have strange behaviour of CFileDialog once it is opened. The offered file name looks like it has been truncated, so that only last n characters are visible: image http://ves.fijmovi.com/cpp/CFileDialog_1.jpg As soon as I click on space for name, I get to see the whole file name: image http://ves.fijmovi.com/cpp/CFileDialog_2.jpg So it is not truly truncated, just the beginning position of shown string is not from the start. The complete file name is in this case 36 characters long and part

Setting the folder view in a CFileDialog (MFC)

蓝咒 提交于 2020-06-27 17:57:07
问题 Is there a standard way to set the folder view in a CFileDialog (Vista-style enabled)? I'm trying to get it to show Details view and some custom columns. I've implemented a Windows 7 column handler that displays app-specific info for files created by my app. However, in order to view these custom columns in an Explorer window or a common file dialog, I have to manually set the folder view to Details then select the specific columns I want. This works fine, but the goal is for the file

文件打开对话框

空扰寡人 提交于 2020-01-12 20:33:44
  CFileDialog类封装了Windows常用的文件对话框。常用的文件对话框提供了一种简单的与Windows标准相一致的文件打开和文件存盘对话框功能。    1 要使用CFileDialog,先用CFileDialog 构造函数 构造一个对象,CFileDialog的构造函数如下: CFileDialog::CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL ); 参数意义如下: bOpenFileDialog 为TRUE则显示 打开对话框 ,为FALSE则显示 保存文件对话框 。 lpszDefExt 指定默认的 文件扩展名 。 lpszFileName 指定默认的文件名。 dwFlags 指明一些特定风格。 lpszFilter 是最重要的一个参数,它指明可供选择的文件类型和相应的扩展名。参数格式如:    "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data

储存应用程序的配置信息ini实现方式

不羁岁月 提交于 2020-01-10 00:25:04
1.C语言中文件操作。 2.C++语言中的文件操作。 3.Win32 API函数文件操作。 4.MFC CFile类文件操作。 5.MFC CFileDialog类的文件操作。 6.注册表文件操作。 下面我来详细说明一下各种文件操作方法: 1. C语言中文件操作.需要包含的头文件STDIO.H   写入文件: FILE *pfile=fopen("C.txt","w");//以写的方式打开C.txt文件。 fwrite("Welcome to VCFans!",1,strlen("Welcome to VCFans!"),pfile);//将数据写入文件。 fflush(pfile);//刷新缓冲区。将缓冲区数据写入文件 fclose(pfile);//关闭文件   读取文件: FILE *pfile=fopen("C.txt","r");//以读的方式打开C.txt文件。 char FileContent[100]; memset(FileContent,0,100);//初始化FileContent fread(FileContent,1,100,pfile);//将刚才C.txt文件中的内容读入到FileContent MessageBox(FileContent);//输出结果 fclose(pfile);//关闭文件 2.C++语言中的文件操作

Problems with CFileDialog instantiation

自闭症网瘾萝莉.ら 提交于 2019-12-19 08:18:11
问题 I'm following the definition for CFileDialog , yet VS2013 is still telling me that there is no constructor available for the arguments that I'm passing in. My Code: CFile theFile; char strFilter[] = { "TXT Files (*.txt)|*.txt|All Files (*.*)|*.*||" }; CFileDialog fDlg = CFileDialog(TRUE, ".txt", NULL, 0, strFilter); Resulting Error: 1 IntelliSense: no instance of constructor "CFileDialog::CFileDialog" matches the argument list argument types are: (int, const char [5], int, int, char [46]) c:

Initial directory is not working for CFileDialog

走远了吗. 提交于 2019-12-10 14:56:20
问题 I am using CFileDialog, I have set the initial path like below , as shown in the code. It's not working . Correct me if I made a mistake. CFileDialog* filedlg = new CFileDialog(TRUE,(LPCTSTR)NULL , (LPCTSTR)NULL , OFN_HIDEREADONLY| OFN_ENABLESIZING , (LPCTSTR)NULL , FromHandle (hImgDlg) ,0 , FALSE ); filedlg ->m_ofn.lpstrInitialDir = "C:\\" ; if ( filedlg ->DoModal() == IDOK ) { /*** do somthing here *****/ } 回答1: If you see the reference for the OPENFILENAME structure, you will see that for

File Operations

烈酒焚心 提交于 2019-12-09 16:56:37
For example: UpdateData(TRUE); CFileDialog dlg(1,NULL,NULL,OFN_HIDEREADONLY ,"All Files(*.*)|*.*||"); if(IDOK!=dlg.DoModal())return; m_filename=dlg.GetPathName(); UpdateData(FALSE); When user click browse button, the function UpdateData(TRUE) will refresh the value from controls to variables. As the same reason, the function UpdateData(FALSE) will refresh the value from variables to controls. #How to open a file with a dialog? The code CFileDialog dlg(1,NULL,NULL,OFN_HIDEREADONLY ,"All Files(*.*)|*.*||"); is supposed to open any files. The following hyperlink contains how to use the

CFileDialog选择多个文件

依然范特西╮ 提交于 2019-12-05 19:23:14
转自: http://my.csdn.net/shuting_guo/code/detail/8522 C++代码: //同时打开N个文件 void COpenNFileDlg::OnButton1() { CString pathName,fileName,fileTitle; char* filters = _T("PCM文件(*.pcm)|*.pcm"); //创建一个可以选择多个文件的CFileDialog CFileDialog fileDlg(true,NULL,"*.pcm",OFN_ALLOWMULTISELECT | OFN_ENABLESIZING | OFN_HIDEREADONLY,filters); //最多可以打开500个文件 fileDlg.m_ofn.nMaxFile = 500 * MAX_PATH; char* ch = new TCHAR[fileDlg.m_ofn.nMaxFile]; fileDlg.m_ofn.lpstrFile = ch; //对内存块清零 ZeroMemory(fileDlg.m_ofn.lpstrFile,sizeof(TCHAR) * fileDlg.m_ofn.nMaxFile); //显示文件对话框,获得文件名集合 if(fileDlg.DoModal() == IDOK){ //获取第一个文件的位置

CFileDialog文件多选

你说的曾经没有我的故事 提交于 2019-12-05 19:22:56
void CMy66Dlg::OnButton4() { #define MAX_CFileDialog_FILE_COUNT 99 #define FILE_LIST_BUFFER_SIZE ((MAX_CFileDialog_FILE_COUNT * (MAX_PATH + 1)) + 1) CString fileName; char* p = fileName.GetBuffer( FILE_LIST_BUFFER_SIZE ); CFileDialog dlgFile(TRUE); OPENFILENAME& ofn = dlgFile.m_ofn;//.GetOFN() ofn.Flags |= OFN_ALLOWMULTISELECT; ofn.lpstrFile = p; ofn.nMaxFile = FILE_LIST_BUFFER_SIZE; POSITION pos = NULL; CString posPaht; if(dlgFile.DoModal()==IDOK){ fileName.ReleaseBuffer(); for(pos=dlgFile.GetStartPosition();pos!=NULL;){ CString str = dlgFile.GetNextPathName(pos); MessageBox(str, _T("提示")); }

MFC CFileDialog 相对路径

丶灬走出姿态 提交于 2019-12-05 19:22:37
1)在mfc中想按照自己设定的路径来打开fileDialog,其实CFileDialog有自己的变量 m_ofn,该变量为OPENFILENAME的结构体,用户可自己定义一些内容 例如 打开窗体的名字: dlg.m_ofn.lpstrTitle = _T("遥测图片加载"); 按照自己设定的路径打开dlg: dlg.m_ofn.lpstrInitialDir = _T("C:\\Documents and Settings\\Administrator\\桌面\\2012.4.16\\DrawProgram1\\YCPicture"); 在这里想说的是,使用相对路径 dlg.m_ofn.lpstrInitialDir = _T("res\\YCPicture"); 总体代码如下: CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,_T("图片文件(*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif| 位图文件 (*.bmp)|*.bmp"),NULL); //dlg.m_ofn.lpstrInitialDir = _T("C:\\Documents and Settings\\Administrator\\桌面\\2012.4.16\\DrawProgram1\