Better Print Preview

One of the biggest advantages to using the MFC document/view architecture is the Print Preview feature. However, this feature is sometimes far less than easy to understand and utilize to its fullest capacity. Therefore, in this article, I'm presenting some improvements to Print Preview that I developed while working on a recent project.

The first thing I did was to eliminate flicker from the preview dialog by utilizing the BitBlt function. You can see an outline of the ExtPreviewView class definition below. This class is derived from the MFC CPreviewView class (described in detail in the MFC Technical Note 30).

The three protected members are used to hold the virtual viewport data. These values are initialized when the InitVxPrintOffset function is called. Therefore, you are able to create a bitmap on a memory DC which is compatible with the Preview DC in MFC for high-speed drawing now that you can get the maximum size of virtual paper.

// override MFC class
class ExtPreviewView : public CPreviewView
{
...
protected:
 // Original viewport point of memory DC
 CSize m_VxPrintOffset;
 CSize m_sizeVxVpExt, m_sizeVxWinExt;
public:
 void InitVxPrintOffset(CDC* pDC);
 ...
 friend class CAdvancedPreviewView;
};
The second improvement I made was to add three additional zoom-in levels.
#define ZOOM_IN_150     3
#define ZOOM_IN_200     4
#define ZOOM_IN_400     5
Caution!

You need to include the gafximpl.h in order to incorporate into your project the source code supplied with this article.

This is how to configure Visual Studio so that it can locate this needed header file.

  1. On the Project menu, click Settings.
  2. In the Settings dialog box, select the C/C++ tab.
  3. Select Preprocessor from the Category drop-down list.
  4. The project-specific include paths are located in the Additional include directories edit box.

Downloads

Download demo project - 28 Kb
Download demo application - 15 Kb


Comments

  • adidas shoes can provide fresh, new life to an old subject. . . golden standardized

    Posted by expopmerm on 03/18/2013 07:24pm

    Odd editorial gives you the run information around nike shoes which only a couple of peopleknow.|Compact guide helps you with most of the ins and outs of nike shoes as well as all that you ought to do right away.}[url=http://www.nikejapan.asia/]シューズナイキ[/url] Know who's talking about nike shoes and the key reasons why you should be concerned. [url=http://www.adidasjapan.biz/]アディダス スニーカー[/url] What you do not know concerning nike shoes may be costing even more than you think. Current information- gucci bags Will certainly Have A Critical role In Almost Any Organization [url=http://www.guccijp.asia/]グッチ 財布[/url] The ultimate technique for the chloe which you may check out right now. [url=http://www.chloejp.biz/]see by chloe[/url] The Primary Approaches To Educate yourself on chanel bags And Also How One Might Enroll with The chanel bags Elite [url=http://www.chaneljp.biz/]財布 chanel[/url] Strategies about how to master just about every thing there is to find relating to chanel purse in eight straight-forward steps.Mystical background about nike shoes that the industry experts do not want you to find out. [url=http://www.adidasjapan.asia/]adidas スニーカー[/url] The modern double strain on nike shoes [url=http://www.nikejp.biz/]nike ランニング[/url] Whatever the pros aren't telling around nike shoes and how it affects you.

    Reply
  • multiple and landscape printing

    Posted by Legacy on 01/23/2004 12:00am

    Originally posted by: yulianto

    Can anyone help me? I`m having problem making program in v c++. I can`t combine multiple printing and landscape orientation. Please send me email if anybody have an idea about it. Thank you.

    Reply
  • i want to print the dialog as it is

    Posted by Legacy on 09/26/2003 12:00am

    Originally posted by: saleem anwar

    dear friends
    i have a dialog based application with some activeX controls on it and i want to print the dailog with that controls. the dialog shape should be the same as on the screen. plz help anyone.

    Reply
  • print handler in VC++

    Posted by Legacy on 04/14/2003 12:00am

    Originally posted by: rahul

    how can handle printer in MDI application
    we have two printer if one faulty then it switch to the next printer.as well as main printer healthy it transfer request to the main printer

    Reply
  • how to modify the print preview's page size and page array size

    Posted by Legacy on 08/13/2002 12:00am

    Originally posted by: huangbo

    Hi:
    
    

    Can you please suggest me how can I modify the preView's
    page size like the microsoft word 2000 preView's page Setup,
    that I can make the page horizontal or vertical ,I can setup the page array size,I can setup the each page size

    Thanx
    huangbo

    Reply
  • How to take a printout of WinDiff file compare tool's expanded view

    Posted by Legacy on 10/22/2001 12:00am

    Originally posted by: suyu

    Hi,
    Can you please suggest me how can I take a printout of the WinDiff tool output in expanded view with all the colour changes reflecting on the printout ??
    Thanx
    Suyu

    • ssss

      Posted by KingHouse on 05/16/2005 03:03am

      sss

      Reply
    Reply
  • GPF on close

    Posted by Legacy on 10/08/2001 12:00am

    Originally posted by: Mike Higginbotham

    Selecting the close button from the preview page GPFs. Any clue as to why? Thanx.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • 10 Rules that Make or Break Enterprise App Development Projects In today's app-driven world, application development is a top priority. Even so, 68% of enterprise application delivery projects fail. Designing and building applications that pay for themselves and adapt to future needs is incredibly difficult. Executing one successful project is lucky, but making it a repeatable process and strategic advantage? That's where the money is. With help from our most experienced project leads and software engineers, …

  • Live Event Date: August 19, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this upcoming webcast to learn various techniques for designing applications that will scale successfully in Bluemix, for the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds