首页上一页 1  下一页尾页 1 条记录 1/1页
        Visual C++ 例6.6
                 	
                        发表在VC++答疑区
                        2015-05-26                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                            Visual C++例6.6中的void CFileDialogDlg::OnOpen() 
{
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.TXT)|*.TXT||"[strong],AfxGetMainWnd()[/strong]);
CString strPath,strText="";
if(dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
m_OpenPath.SetWindowText(strPath);
CFile file(strPath,CFile::modeRead);
char read[10000];
file.Read(read,10000);
for(int i=0;i<file.GetLength();i++)
{
strText += read[i];
}
file.Close();
m_FileText.SetWindowText(strText);
}
}
void CFileDialogDlg::OnSave()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.TXT)|*.TXT||",AfxGetMainWnd());
CString strPath,strText="";
char write[10000];
if(dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
if(strPath.Right(4) != ".TXT")
strPath += ".TXT";
m_SavePath.SetWindowText(strPath);
CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite);
m_FileText.GetWindowText(strText);
strcpy(write,strText);
file.Write(write,strText.GetLength());
file.Close();
}
}
上面的AfxGetMainWnd());
CString strPath,strText="";
file.Close();
不知道这三句怎么理解?
        
                
        	
        
        
    {
// TODO: Add your control notification handler code here
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.TXT)|*.TXT||"[strong],AfxGetMainWnd()[/strong]);
CString strPath,strText="";
if(dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
m_OpenPath.SetWindowText(strPath);
CFile file(strPath,CFile::modeRead);
char read[10000];
file.Read(read,10000);
for(int i=0;i<file.GetLength();i++)
{
strText += read[i];
}
file.Close();
m_FileText.SetWindowText(strText);
}
}
void CFileDialogDlg::OnSave()
{
// TODO: Add your control notification handler code here
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.TXT)|*.TXT||",AfxGetMainWnd());
CString strPath,strText="";
char write[10000];
if(dlg.DoModal() == IDOK)
{
strPath = dlg.GetPathName();
if(strPath.Right(4) != ".TXT")
strPath += ".TXT";
m_SavePath.SetWindowText(strPath);
CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite);
m_FileText.GetWindowText(strText);
strcpy(write,strText);
file.Write(write,strText.GetLength());
file.Close();
}
}
上面的AfxGetMainWnd());
CString strPath,strText="";
file.Close();
不知道这三句怎么理解?

 
	
                                                 VIP会员
VIP会员 购物车
购物车


 私信
                         私信 
                     发表新帖
发表新帖 立即签到
立即签到 
        		  
        		 
         		 关注
关注
                  回复
 回复 支持(
                	支持( 反对(
                    反对( 
               			  
                







 
                     
                     
					 
						 
						 
						 
						