首页上一页 1  下一页尾页 4 条记录 1/1页
        请教<>第5章 实例1 
                 	
                        发表在C语言图书答疑
                        2009-04-30                                                
                    		
                                                                            	
                        
                        
                    
                    
                    	是否精华
                    	是
                    	否
                    
                    
                    
                            版块置顶:
                            是
                            否
                        
                    
                                           急啊,我照着书上的例子输入代码,编译通过了,但点"!"时程序没什么反应
也为Rich Edit 控件添加了变量m_RichEdit,也按书上的属性设置
代码我也加入了,如下(直接从光盘中复制的)
void COpenAndSaveDlg::OnButton1()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.*)|*.*| |",AfxGetMainWnd());
CString strPath,strText="";
if(dlg.DoModal() == IDOK)
{
strPath=dlg.GetPathName();
}
CFile file(strPath,CFile::modeRead);
char read[1000];
file.Read(read,1000);
for(int i=0;i<file.GetLength();i++)
{
strText += read[i];
}
file.Close();
m_RichEdit.SetWindowText(strText);
}
void COpenAndSaveDlg::OnButton2()
{
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.*)|*.*| |",AfxGetMainWnd());
CString strPath,strText="";
char write[1000];
if(dlg.DoModal()==IDOK)
{
strPath=dlg.GetPathName();
if(strPath.Right(4)!=".txt")
strPath+=".txt";
}
CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite);
m_RichEdit.GetWindowText(strText);
strcpy(write,strText);
file.Write(write,strText.GetLength());
file.Close();
}
        
                
        	
        
        
    也为Rich Edit 控件添加了变量m_RichEdit,也按书上的属性设置
代码我也加入了,如下(直接从光盘中复制的)
void COpenAndSaveDlg::OnButton1()
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.*)|*.*| |",AfxGetMainWnd());
CString strPath,strText="";
if(dlg.DoModal() == IDOK)
{
strPath=dlg.GetPathName();
}
CFile file(strPath,CFile::modeRead);
char read[1000];
file.Read(read,1000);
for(int i=0;i<file.GetLength();i++)
{
strText += read[i];
}
file.Close();
m_RichEdit.SetWindowText(strText);
}
void COpenAndSaveDlg::OnButton2()
{
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"All Files(*.*)|*.*| |",AfxGetMainWnd());
CString strPath,strText="";
char write[1000];
if(dlg.DoModal()==IDOK)
{
strPath=dlg.GetPathName();
if(strPath.Right(4)!=".txt")
strPath+=".txt";
}
CFile file(_T(strPath),CFile::modeCreate|CFile::modeWrite);
m_RichEdit.GetWindowText(strText);
strcpy(write,strText);
file.Write(write,strText.GetLength());
file.Close();
}

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

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







 
                     
                     
					 
						 
						 
						 
						