15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Trouble with CRIchEdit

Ken Miller -- kmiller@ccse.net
Monday, October 28, 1996

Environment: VC++ 4.0, Windows 95

I am trying to create a program that will read ASCII and format it and then
save it as RTF.  I want to be able to put the ASCII in a pane (left side)
and the RTF in another pane (right pane).  This is the problem.

I created the app using the CRichEditView and CRichEditDoc, then I
added the CEditView.  I then created two panes with the CRichEditView on
the right and the CEditView on the left.

I added the code to open the file and then tried to get each line from the
left
pane in preparation for sending it to my parser, but ran into a problem. 
When I tried to open the file it gave me a wrong format error.

I am also confused on something.  The document is a CRichEditDoc.
 So I set the flag m_bRTF to false to allow me to load an ASCII file.  
I then want to format the text and put it into the CRichEditView pane, 
but with RTF formatting.  I then want to save it as a RTF file.  
How can I do all this with the same document, which is a CRichEditDoc?

Here is what I did:

void CPP95Doc::OnFileOpen() 
{
	// TODO: Add your command handler code here
	static char BASED_CODE szFilter[] = "C Source Files (*.c)|*.c||";
	
	CFileDialog dlg(TRUE,NULL,NULL,NULL,szFilter);

	if(dlg.DoModal() == IDOK)
	{
		m_File1 = m_File2 = dlg.GetPathName();
		Formatter(m_File1);
	}
}

void CPP95Doc::Formatter(LPCSTR lpszFile1)
{
	char buffer[101];

	CMainFrame *pFrame = CPP95App::GetApp()->GetMainFrame();

	if(pFrame)
	{
		CSplitter *pSplitter = pFrame->GetSplitter();

		if(pSplitter)
		{
			CASCIIView *pASCIIView;
			CRTFView   *pRTFView;

			pASCIIView = (CASCIIView *)pSplitter->GetPane(0,0);

			if(pASCIIView)
			{
				CFile file(lpszFile1, CFile::modeRead);
				CArchive ar(&file, CArchive::load);
				pASCIIView->Serialize(ar);

				pASCIIView->GetEditCtrl().SetReadOnly();
				int lines = pASCIIView->GetEditCtrl().GetLineCount();

				for(int x=0; xGetEditCtrl().GetLine(x,buffer,100);
				}

			}

			SetModifiedFlag(FALSE);
		}
	}
}





Ken Miller -- kmiller@ccse.net
Monday, November 04, 1996

Environment: VC++ 4.0, Windows 95

Hi, I sent this message a little bit ago and haven't heard anything.  Is it
possible that if someone can't answer it that they could point me in the
right direction for a reference on how to do this?  It would be much
appreciated.

Thanks in advance...Ken

> I am trying to create a program that will read ASCII and format it and
then
> save it as RTF.  I want to be able to put the ASCII in a pane (left side)
> and the RTF in another pane (right pane).  This is the problem.
> 
> I created the app using the CRichEditView and CRichEditDoc, then I
> added the CEditView.  I then created two panes with the CRichEditView on
> the right and the CEditView on the left.
> 
> I added the code to open the file and then tried to get each line from
the
> left
> pane in preparation for sending it to my parser, but ran into a problem. 
> When I tried to open the file it gave me a wrong format error.
> 
> I am also confused on something.  The document is a CRichEditDoc.
>  So I set the flag m_bRTF to false to allow me to load an ASCII file.  
> I then want to format the text and put it into the CRichEditView pane, 
> but with RTF formatting.  I then want to save it as a RTF file.  
> How can I do all this with the same document, which is a CRichEditDoc?
> 
> Here is what I did:
> 
> void CPP95Doc::OnFileOpen() 
> {
> 	// TODO: Add your command handler code here
> 	static char BASED_CODE szFilter[] = "C Source Files (*.c)|*.c||";
> 	
> 	CFileDialog dlg(TRUE,NULL,NULL,NULL,szFilter);
> 
> 	if(dlg.DoModal() == IDOK)
> 	{
> 		m_File1 = m_File2 = dlg.GetPathName();
> 		Formatter(m_File1);
> 	}
> }
> 
> void CPP95Doc::Formatter(LPCSTR lpszFile1)
> {
> 	char buffer[101];
> 
> 	CMainFrame *pFrame = CPP95App::GetApp()->GetMainFrame();
> 
> 	if(pFrame)
> 	{
> 		CSplitter *pSplitter = pFrame->GetSplitter();
> 
> 		if(pSplitter)
> 		{
> 			CASCIIView *pASCIIView;
> 			CRTFView   *pRTFView;
> 
> 			pASCIIView = (CASCIIView *)pSplitter->GetPane(0,0);
> 
> 			if(pASCIIView)
> 			{
> 				CFile file(lpszFile1, CFile::modeRead);
> 				CArchive ar(&file, CArchive::load);
> 				pASCIIView->Serialize(ar);
> 
> 				pASCIIView->GetEditCtrl().SetReadOnly();
> 				int lines = pASCIIView->GetEditCtrl().GetLineCount();
> 
> 				for(int x=0; x 				{
> 					pASCIIView->GetEditCtrl().GetLine(x,buffer,100);
> 				}
> 
> 			}
> 
> 			SetModifiedFlag(FALSE);
> 		}
> 	}
> }
> 
> 




| Вернуться в корень Архива |