C++对话框资源
源代码在线查看: recite.txt
CFileDialog FileDlg(TRUE, "*.txt", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "(*.txt)|*.txt||");
FileDlg.DoModal();
CString cstrFileName;
cstrFileName = FileDlg.GetPathName();
//未选中任何文件
if ("" == cstrFileName)
{
return ;
}
CFile file;
char* pszBuff = NULL;
if (file.Open(cstrFileName.GetString(), CFile::modeReadWrite | CFile::shareDenyWrite))
{
ULONGLONG ullLeng = 0;
ullLeng = file.GetLength();
pszBuff = new char[ullLeng];//分配内存资源
ZeroMemory(pszBuff, ullLeng);
file.Read(pszBuff, ullLeng);
file.Close();
}
//写入编辑框
m_edtText.SetWindowText(pszBuff);
//释放内存资源
if (NULL != pszBuff)
{
delete [] pszBuff;
}