MFC CFileDialog用法例子。

?Set it to?TRUE?to construct a?File Open?dialog box. Set it to?FALSE?to construct a?File Save As?dialog box.


void CCompFileDlg::OnDirbrowser()

{

????// TODO: Add your control notification handler code here

????CFileDialog fileDialog(TRUE);

????if (fileDialog.DoModal() == IDOK) {

????????CString pathName = fileDialog.GetPathName();

????????int index = pathName.ReverseFind(‘\\‘);

????????if (index == -1) {

????????????AfxMessageBox(L"The Directory is not correct!");

????????????return;

????????}

????????m_DirPathString = pathName.Left(index);

????????UpdateData(FALSE);

????}

}

?

void CCompFileDlg::OnFilebrowser()

{

????// TODO: Add your control notification handler code here

????CFileDialog fileDialog(FALSE);

????if (fileDialog.DoModal() == IDOK) {

????????m_FilePathString = fileDialog.GetPathName();

????????UpdateData(FALSE);

????}

}

?

时间: 2024-08-30 07:35:35

MFC CFileDialog用法例子。的相关文章

Win32 实现 MFC CFileDialog 对话框

void CWriteWnd::OpenFileDialog(){    OPENFILENAME ofn;          TCHAR szFile[MAX_PATH] = _T(""); ZeroMemory(&ofn, sizeof(ofn));      ofn.lStructSize = sizeof(ofn);    ofn.hwndOwner   = *this;    ofn.lpstrFile   = szFile;       ofn.nMaxFile  

c# 反射简单用法例子

闲来无事,看了下反射的实现,写了个小例子. 新建一个类: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace WfmReflection { class MyClass { public string m; public void test() { } public int MyProperty { get; set; } } } 建一个类库 using S

MFC CFileDialog使用整理

1.CFileDialog构造函数 CFileDialog:CFileDialog(BOOL     bOpenFileDialog, LPCTSTR     lpszDefExt=NULL, LPCTSTR     lpszFileName=NULL, DWORD     dwFlags     =     OFN_HIDEREADONLY     |     OFN_OVERWRITEPROMPT, LPCTSTR     lpszFilter=NULL, CWnd     *     pP

MFC中CFileDialog用法

用CFileDialog选择了一个文件后,使用FILE::fopen打开文件错误,使用 的是相对地址,和王工调试了半天,怎么跟踪也没发现错误,原来如此......... CFileDialog文件选择对话框的使用:首先构造一个对象并提供相应的参数,构造函数原型如下: CFileDialog::CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlag

C/C++/MFC时间用法

1. C\C++中用法 /* strftime example */ #include <stdio.h>      /* puts */ #include <time.h>       /* time_t, struct tm, time, localtime, strftime */ int main () { time_t rawtime; struct tm * timeinfo; char buffer [80]; time (&rawtime); timeinf

MFC——ComBox用法大全

Combo Box (组合框)控件很简单,可以节省空间.从用户角度来看,这个控件是由一个文本输入控件和一个下拉菜单组成的.用户可以从一个预先定义的列表里选择一个选项,同时也可以直接在文本框里面输入文本.下面的例子简要说明如何利用 MFC CComboBox Class来操作字符串列表. 1.定义控件对应变量 假定已经创建了一个Dialog,并且从控件工具箱将 Combo Box 控件拖放到上面.打开 Class Wizard,添加控件对应变量,如:CComboBox m_cbExamble; 在

MFC CFileDialog派生类在编译过程出现“error 没有与参数列表匹配的构造函数......”的问题

CFileDialog派生类在编译过程出现"error 没有与参数列表匹配的构造函数实例参数类型为(int,const char[4],const char[6],int,const char[36],int)  .的问题 解决办法 右击项目---属性----配置属性-----常规-----字符集  选择"使用多字节字符集"即可~~~~撒花~~

VS MFC CFileDialog类 打开文件对话框和另存为对话框

1 explicit CFileDialog( 2 BOOL bOpenFileDialog, 指定的参数创建哪种类型的对话框. 设置到构造 文件已打开 对话框的 TRUE. 设置到构造 保存文件 对话框的 FALSE. 3 LPCTSTR lpszDefExt = NULL, 默认的文件扩展名. 如果用户在文件名框中不包括包含在用户的计算机上的关联) 的已知扩展 (一,lpszDefExt 指定的扩展自动追加到文件名. 如果此参数是 NULL,扩展不是追加. 4 LPCTSTR lpszFil

foreach 用法例子

例子图.......... 例子1  foreach获取动态IP foreach循环获取ip addr下的所有动态的IP (find dynamic=yes,查找动态的) do={:put  利用get获取IP}