在现有的Visual C++ 上进行怎样的升级才能使CFileOpen 打开的是新的界面,而不是老式的界面

syberprince 2002-03-26 03:32:28
在现有的Visual C++ 上进行怎样的升级才能使CFileOpen 打开的是新的界面,而不是老式的界面
...全文
45 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
syberprince 2002-03-26
  • 打赏
  • 举报
回复
richarld79@sina.com
谢谢
baoch110 2002-03-26
  • 打赏
  • 举报
回复
留下邮件地址,我给你发一个界面的源代码
试试看
syberprince 2002-03-26
  • 打赏
  • 举报
回复
不需要重绘,好像是把一些包含的头文件更新就行了
有人知道吗?
fantong 2002-03-26
  • 打赏
  • 举报
回复
考,这么快就这么多回应了,看来俺捞不到多少分了
fantong 2002-03-26
  • 打赏
  • 举报
回复
还有一种办法,直接用SDK写问打开文件对话框,比如
LPTSTR pFileNameBuf=new TCHAR[65536];
ZeroMemory(pFileNameBuf,65536);

OPENFILENAME ofn; // older version

memset(&ofn, 0, sizeof(ofn));

ofn.lStructSize = sizeof(ofn);

static char BASED_CODE szFilter[] = "All Files (*.*)|*.*||";
ofn.lpstrFilter=szFilter;

ofn.lpstrFile=pFileNameBuf;
ofn.nMaxFile=65535;
ofn.Flags=OFN_ALLOWMULTISELECT|OFN_ENABLESIZING|OFN_EXPLORER|OFN_FILEMUSTEXIST;
ofn.hwndOwner=GetSafeHwnd();
int nResult = ::GetOpenFileName(&ofn);

if(nResult==0) {
DWORD ErrorCode=CommDlgExtendedError();
//FNERR_BUFFERTOOSMALL
delete pFileNameBuf;
return;
}
不过这样处理多个文件的时候有点麻烦,
要先写两个函数
POSITION GetStartPosition(OPENFILENAME &m_ofn){
return (POSITION)m_ofn.lpstrFile;
}
CString GetNextPathName(POSITION& pos,OPENFILENAME &m_ofn)
{
BOOL bExplorer = m_ofn.Flags & OFN_EXPLORER;
TCHAR chDelimiter;
if (bExplorer)
chDelimiter = '\0';
else
chDelimiter = ' ';

LPTSTR lpsz = (LPTSTR)pos;
if (lpsz == m_ofn.lpstrFile) // first time
{
if ((m_ofn.Flags & OFN_ALLOWMULTISELECT) == 0)
{
pos = NULL;
return m_ofn.lpstrFile;
}

// find char pos after first Delimiter
while(*lpsz != chDelimiter && *lpsz != '\0')
lpsz = _tcsinc(lpsz);
lpsz = _tcsinc(lpsz);

// if single selection then return only selection
if (*lpsz == 0)
{
pos = NULL;
return m_ofn.lpstrFile;
}
}

CString strPath = m_ofn.lpstrFile;
if (!bExplorer)
{
LPTSTR lpszPath = m_ofn.lpstrFile;
while(*lpszPath != chDelimiter)
lpszPath = _tcsinc(lpszPath);
strPath = strPath.Left(lpszPath - m_ofn.lpstrFile);
}

LPTSTR lpszFileName = lpsz;
CString strFileName = lpsz;

// find char pos at next Delimiter
while(*lpsz != chDelimiter && *lpsz != '\0')
lpsz = _tcsinc(lpsz);

if (!bExplorer && *lpsz == '\0')
pos = NULL;
else
{
if (!bExplorer)
strFileName = strFileName.Left(lpsz - lpszFileName);

lpsz = _tcsinc(lpsz);
if (*lpsz == '\0') // if double terminated then done
pos = NULL;
else
pos = (POSITION)lpsz;
}

// only add '\\' if it is needed
if (!strPath.IsEmpty())
{
// check for last back-slash or forward slash (handles DBCS)
LPCTSTR lpsz = _tcsrchr(strPath, '\\');
if (lpsz == NULL)
lpsz = _tcsrchr(strPath, '/');
// if it is also the last character, then we don't need an extra
if (lpsz != NULL &&
(lpsz - (LPCTSTR)strPath) == strPath.GetLength()-1)
{
ASSERT(*lpsz == '\\' || *lpsz == '/');
return strPath + strFileName;
}
}
return strPath + '\\' + strFileName;
}
然后你就可以快乐的这样访问了
CString FullPathName;
CString sFileLen;
POSITION pos;

pos=GetStartPosition(ofn);
UINT itemcount=m_FileList.GetItemCount();
LVITEM lvitem;
lvitem.mask=LVIF_TEXT;
m_FileList.SetRedraw(FALSE);
while(pos!=NULL)
{
FullPathName=GetNextPathName(pos,ofn);
if(!IsDuplicate(&m_FileList,FullPathName)) {

lvitem.pszText=(TCHAR*)(LPCSTR)FullPathName;
lvitem.iItem=itemcount;
lvitem.iSubItem=0;
itemcount=m_FileList.InsertItem(&lvitem);

sFileLen=GetFileLenByString(FullPathName);
lvitem.iSubItem=1;
lvitem.pszText=(TCHAR*)(LPCSTR)sFileLen;
m_FileList.SetItem(&lvitem);
}

}
delete pFileNameBuf;
vcbacker 2002-03-26
  • 打赏
  • 举报
回复
试试这个:

CFileDialog dlgFile;
dlgFile.m_ofn.lpstrFilter=_T("所有文件(*.*)\0*.*\0");
int structsize=0;
DWORD dwVersion,dwWindowsMajorVersion,dwWindowsMinorVersion;
dwVersion = GetVersion();
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if(dwVersion < 0x80000000)
structsize = 88;
else
structsize = 76;
dlgFile.m_ofn.lStructSize=structsize;
TCHAR lpstrFilename[MAX_PATH]=_T("");
dlgFile.m_ofn.lpstrFile=lpstrFilename;
if(dlgFile.DoModal()==IDOK)
MessageBox("你所打开的文件是:"+(CString)dlgFile.m_ofn.lpstrFile);
else
MessageBox("打开文件出错!");
masterz 2002-03-26
  • 打赏
  • 举报
回复
In order to access Win2000 specific APIs etc, one needs the following #define in the application's stdafx.h (before any other #includes)
#define _WIN32_WINNT 0x0500

Header File Conventions
This Platform can be used to target applications for Microsoft Windows NT® 4.0, and Microsoft Windows 2000 using the header file conventions below.

The makefiles generated by Microsoft Visual C++® 5.0 and 6.0 target Windows NT 3.51 by default. Therefore, to use functions introduced in Windows NT 4.0 or later, which are protected by conditional code, you must define the appropriate macros. Otherwise, you will receive the following error message from the compiler: error C2065: undeclared identifier. You may also need to ensure that the INCLUDE environment variables has the path to the SDK header files listed before the path to the Visual C++ header files. Otherwise, you will receive error C2065 for items that were introduced after Visual C++ was released.

The following table indicates the macros you must define to target each system using the SDK headers.

Minimum System Required Macros to Define
Windows 95 and Windows NT 4.0 WINVER=0x0400
Windows 98 and Windows NT 4.0 _WIN32_WINDOWS=0x0410 and WINVER=0x0400
Windows NT 4.0 _WIN32_WINNT=0x0400 and WINVER=0x0400
Windows 98 and Windows 2000 WINVER=0x0500
Windows 2000 _WIN32_WINNT=0x0500 and WINVER=0x0500
Internet Explorer 3.0 _WIN32_IE=0x0300
Internet Explorer 4.0 _WIN32_IE=0x0400
Internet Explorer 5.0 _WIN32_IE=0x0500


ju_feng 2002-03-26
  • 打赏
  • 举报
回复
只好自己用api写了!
蒋晟 2002-03-26
  • 打赏
  • 举报
回复
Use OPENFILENAME instead of CFileDialog
eggaig 2002-03-26
  • 打赏
  • 举报
回复
更改消息映射,
自己画一个Dialog.
你说呢?

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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