Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi everybody,

I am posting this question because I am stuck on "Loading an .rtf file from the resources and change some values before Print-Preview it".

- The content of the .rtf file may contain some variables to replace (i.e: @Unit Price@ or @Date and Time@ or something between the two @).
- The content of the .rtf file will be visible only when you click "Print Preview" from the main menu.
- The main application is an SDI app with a main view class of a CFormView type, so the content of the .rtf file will not be visible.
- @Unit Price@ and @Date and Time@ will be replaced with values retrieved from some CEdit edit boxes from the main CFormView view.
- If I have: m_EdtUnitPrice = "$200.00" and m_EdtDateAndTime = "09/28/2012" and:
- The content of the .rtf file Before was:
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla @Unit Price@ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla @Date an Time@ bla bla bla bla bla bla bla bla bla bla bla bla bla.

So after I click "Print Preview" from the main menu:
- The content of the .rtf file After will be:
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla $200.00 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla 09/28/2012 bla bla bla bla bla bla bla bla bla bla bla bla bla.

The Load Code:
void CGLVImpressionView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
	HRSRC hRsrc = ::FindResource(NULL, _T("Print Preview.rtf"), _T("RTF"));
	if (hRsrc == NULL)
		return;
	
	HGLOBAL hGlobal = ::LoadResource(NULL, hRsrc);
	if (hGlobal == NULL)
		return;
	
	LPTSTR pData = (LPTSTR)::LockResource(hGlobal);
	if (pData == NULL)
		return;
	
	DWORD dwSize = ::SizeofResource(NULL, hRsrc);
	if (dwSize == 0)
		return;
				...
			// Whats next !?
			// How to replace the pData content variables: @Unit Price@ and @Date an Time@ !?
			// How to make the loaded .rtf show in Print Preview !?
				...
}


Thank you for your understanding.
Posted
Updated 28-Sep-12 16:20pm
v11
Comments
Joan M 28-Sep-12 11:26am    
Re-read your question and try to do it from the perspective of someone that has no idea of your problem. If you do that small exercise you will see that it is impossible to answer anything.
Please, elaborate your question a little bit more, give us details, show us your code fragment you want us to check or to give advice to you...
Read the posting guidelines...
Better questions usually give better answers...
n.podbielski 28-Sep-12 11:38am    
++
Mr. Tomay 28-Sep-12 11:43am    
updated
Mr. Tomay 28-Sep-12 11:43am    
updated
Joan M 28-Sep-12 11:48am    
I guess that if you are stuck you will have some code or some specific issue... What is exactly not working? I understand a set of requisites, but I can't see what you've tried till now and what is failing or misbehaving. We don't make other people's work, so we expect a little effort from the OP. Probably you've done that effort, but with your question (even in version 3) it looks more something like "please make the job for me" than a question itself.

This is not a proper question it is only a gimmecode post...

Take a look here:
http://www.codeproject.com/search.aspx?q=richedit+mfc&doctypeid=1%3b2%3b3[^]
 
Share this answer
 
Your answer lies here[^]. Go forth and prosper.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900