<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : Print Preview Prebuilt Sample</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Toolkit Pro : Print Preview Prebuilt Sample]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Tue, 21 Apr 2026 10:02:57 +0000</pubDate>
  <lastBuildDate>Thu, 01 Apr 2010 11:02:14 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=16542</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[Print Preview Prebuilt Sample : Okay, I figured out how to fix...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=16542&amp;PID=57895&amp;title=print-preview-prebuilt-sample#57895</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5902">CyberSky</a><br /><strong>Subject:</strong> 16542<br /><strong>Posted:</strong> 01 April 2010 at 11:02am<br /><br /><P>Okay, I figured out how to fix this to get the behavior I want.</P><P>If you look at the code for CPrintPreviewState:</P><P>struct CPrintPreviewState&nbsp;&nbsp;&nbsp; // Print Preview context/state<BR>{<BR>&nbsp;&nbsp;&nbsp; ...<BR>&nbsp;&nbsp;&nbsp; BOOL (CALLBACK* lpfnCloseProc)(CFrameWnd* pFrameWnd);<BR>&nbsp;&nbsp;&nbsp; ...<BR>};</P><P>you can see there's a function that's supposed to get called when you close print preview. This is _AfxPreviewCloseProc(). I think it should be called if you click Close Preview on the toolbar or the application's Close button. However, it apparently is only called if you click Close Preview. If you click Close, the application closes instead.</P><P>When the main frame's OnSetPreviewMode() is called you can save the preview state:</P><P>void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState)<BR>{<BR>&nbsp;&nbsp;&nbsp; m_bPrintPreviewMode = bPreview;</P><DIV>&nbsp;&nbsp;&nbsp; m_pPrintPreviewState = pState;<BR>&nbsp;&nbsp;&nbsp; ...</DIV><P>&nbsp;&nbsp;&nbsp; // Show or hide the command bars, docking panes, etc.<BR>}</P><P>and then in OnClose() call the preview close procedure rather than the normal code to close the application:</P><P>void CMainFrame::OnClose()<BR>{<BR>&nbsp;&nbsp;&nbsp; if (m_bPrintPreviewMode)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (m_pPrintPreviewState-&gt;lpfnCloseProc != NULL)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (*m_pPrintPreviewState-&gt;lpfnCloseProc)(this);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P><DIV>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Save the current state of the main window, command bars, etc.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...</DIV><P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CFrameWnd::OnClose();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>}</P><P>Now when the program is in print preview mode, clicking Close will close print preview rather than closing the entire application.</P><P>I hope somebody finds this useful.</P>]]>
   </description>
   <pubDate>Thu, 01 Apr 2010 11:02:14 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=16542&amp;PID=57895&amp;title=print-preview-prebuilt-sample#57895</guid>
  </item> 
  <item>
   <title><![CDATA[Print Preview Prebuilt Sample : I&amp;#039;ve noticed that in my software...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=16542&amp;PID=57860&amp;title=print-preview-prebuilt-sample#57860</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=5902">CyberSky</a><br /><strong>Subject:</strong> 16542<br /><strong>Posted:</strong> 31 March 2010 at 12:54am<br /><br /><P>I've noticed that in my software clicking the Close button in the upper-right corner of the window while in print preview closes the entire application rather than just closing pring preview. I checked the Codejock sample and don't understand what I'm seeing.</P><DIV></DIV>If I run the prebuilt ToolkitPro.PrintPreview sample that comes with the AllSamples.zip available here, then the print preview fills the entire window. Clicking the Close button (X) does the same thing as clicking the Close Preview button on the print preview toolbar.<DIV>&nbsp;</DIV><DIV>However, if I build the PrintPreview sample that's in the Toolkit Pro sample folder, and then run it, it behaves differently. The print preview doesn't fill the entire window (the menu bar is still visible), and clicking the Close button (X) closes the entire application rather than closing just the print preview.</DIV><DIV>&nbsp;</DIV><DIV>I'm talking about the latest version 13.3.1, and am using VS2008 on Windows 7 64-bit.</DIV><DIV>&nbsp;</DIV><DIV>I've noticed that a basic MFC program also behaves the same way: the Close button closes the entire application rather than just print preview.</DIV><DIV>&nbsp;</DIV><DIV>Anybody else notice this? Anybody know why the prebuilt sample works one way and the one I built (not changing any options) works a different way?</DIV><DIV>&nbsp;</DIV><DIV>Thanks for any comments!</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 31 Mar 2010 00:54:37 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=16542&amp;PID=57860&amp;title=print-preview-prebuilt-sample#57860</guid>
  </item> 
 </channel>
</rss>