要打开一个文件,用什么控件 我在DIALOG上点击“打开” 按钮,就要弹出对话框让我选择文件,功能类似于常见软件中的“打开”菜单,用什么控件啊》 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 通用的对话框类中的CFileDialog! 不用什么控件的,直接调用通用对话框的类就可以了!CFileDialog! BOOL bOpenFileDialog = TRUE; LPCTSTR lpszDefExt = NULL; LPCTSTR lpszFileName = NULL; DWORD dwFlags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ALLOWMULTISELECT | 0; LPCTSTR lpszFilter = _T("Word 文档 (*.doc)|*.doc|WPS 文档 (*.wps)|*.wps|BMP 位图文件 (*.bmp)|*.bmp|All Files (*.*)|*.*||"); CWnd* pParentWnd = ::AfxGetMainWnd(); CFileDialog fileDialog(bOpenFileDialog, _T(""), NULL, dwFlags, lpszFilter, pParentWnd); fileDialog.m_ofn.hInstance = ::AfxGetInstanceHandle(); if (IDOK == fileDialog.DoModal()) { CString strFileName = _T(""); // 文件名 CString strPathName = _T(""); // 路径 strPathName = fileDialog.GetPathName(); strFileName = fileDialog.GetFileName(); strFileName = strPathName.Mid(nIndex + 1); CFile file; if (!file.Open((LPCTSTR)strPathName, CFile::modeRead | CFile::shareDenyWrite, NULL)) { ...} else { ... } 不是控件啊,那时MFC中封装的一个类 w7系统下HCPAINT消息处理了//为什么还显示之前的标题栏??? 客户端是VC++6.0编写,但是因为要求服务器端用C#网页编写? 怎样把一个mfc的dialog做成ActiveX控件加入到htm页面中? 求购 《ATL 开发指南(第二版)》 关于vc的两个问题 有关View的创建 进程间的通信?sendmessage? 请教一个在vc下嵌套汇编语言的问题 分析mfc源码有用吗? MFC同时采集串口和USB数据采集卡 有没有办法在其他程序中的鼠标右键菜单添加自己的功能? 基于对话框的程序怎样加菜单
LPCTSTR lpszDefExt = NULL;
LPCTSTR lpszFileName = NULL;
DWORD dwFlags = OFN_HIDEREADONLY |
OFN_EXPLORER |
OFN_ALLOWMULTISELECT |
0;
LPCTSTR lpszFilter = _T("Word 文档 (*.doc)|*.doc|WPS 文档 (*.wps)|*.wps|BMP 位图文件 (*.bmp)|*.bmp|All Files (*.*)|*.*||");
CWnd* pParentWnd = ::AfxGetMainWnd();
CFileDialog fileDialog(bOpenFileDialog, _T(""), NULL, dwFlags, lpszFilter, pParentWnd);
fileDialog.m_ofn.hInstance = ::AfxGetInstanceHandle(); if (IDOK == fileDialog.DoModal())
{
CString strFileName = _T(""); // 文件名
CString strPathName = _T(""); // 路径
strPathName = fileDialog.GetPathName(); strFileName = fileDialog.GetFileName(); strFileName = strPathName.Mid(nIndex + 1);
CFile file;
if (!file.Open((LPCTSTR)strPathName,
CFile::modeRead | CFile::shareDenyWrite,
NULL))
{ ...}
else {
...
}