Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 28-Sep-12 6:07am
tomay30001.2K
Edited 28-Sep-12 17:20pm
v11
Comments
Joan Murt at 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 at 28-Sep-12 11:38am
   
++
tomay3000 at 28-Sep-12 11:43am
   
updated
tomay3000 at 28-Sep-12 11:43am
   
updated
Joan Murt at 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.
tomay3000 at 28-Sep-12 12:16pm
   
could you please see version 4
Joan Murt at 28-Sep-12 12:22pm
   
Have you done any code yet on that issue where you are stuck?
tomay3000 at 28-Sep-12 12:36pm
   
sure, see version 8
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Your answer lies here[^]. Go forth and prosper.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 290
1 Jochen Arndt 150
2 Kornfeld Eliyahu Peter 149
3 PIEBALDconsult 110
4 Richard MacCutchan 105
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100