Bug: printing of a specific page range is broken in MFC-VS2005

If you create an MFC application that includes printing support, and your 
application does print-time pagination as described in this MSDN library 
topic:
http://msdn2.microsoft.com/en-us/library/w7wzay73(VS.80).aspx
then specifying printing of a specific range of pages in the print dialog 
does not work. The application always prints all pages of the document.

To see this problem download and build the WordPad sample MFC application. 
Start a new blank document, then paste into it enough text to fill several 
pages. Choose Print from the File menu. Choose a print range of page 1 to 
page 1. Click OK. All pages will print instead of just the first page.

The bug is not in WordPad, but in the MFC library module viewprnt.cpp in the 
CView::OnFilePrint function in this code:

// page successfully started, so now render the page
OnPrint(&dcPrint, &printInfo);
if (nStep > 0) // pages are printed in ascending order
{
	// OnPrint may have set the last page
	// because the end of the document was reached.
	// The loop must not continue with the next iteration.
	nEndPage = printInfo.GetMaxPage() + nStep; 
}

The call to GetMaxPage overwrites the value of nEndPage which was originally 
set from the page range specified by the user in the print dialog. The result 
is that all pages of the document are printed, regardless of what the user 
requested.

Jeff Bean
CWC Software
0
JWBean (1)
5/31/2007 10:21:01 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
321 Views

Similar Articles

[PageSpeed] 43

>If you create an MFC application that includes printing support, and your 
>application does print-time pagination as described in this MSDN library 
>topic:
>http://msdn2.microsoft.com/en-us/library/w7wzay73(VS.80).aspx
>then specifying printing of a specific range of pages in the print dialog 
>does not work. The application always prints all pages of the document.
>
>To see this problem download and build the WordPad sample MFC application. 
>Start a new blank document, then paste into it enough text to fill several 
>pages. Choose Print from the File menu. Choose a print range of page 1 to 
>page 1. Click OK. All pages will print instead of just the first page.
>
>The bug is not in WordPad, but in the MFC library module viewprnt.cpp in the 
>CView::OnFilePrint function in this code:
>
>// page successfully started, so now render the page
>OnPrint(&dcPrint, &printInfo);
>if (nStep > 0) // pages are printed in ascending order
>{
>	// OnPrint may have set the last page
>	// because the end of the document was reached.
>	// The loop must not continue with the next iteration.
>	nEndPage = printInfo.GetMaxPage() + nStep; 
>}
>
>The call to GetMaxPage overwrites the value of nEndPage which was originally 
>set from the page range specified by the user in the print dialog. The result 
>is that all pages of the document are printed, regardless of what the user 
>requested.

Jeff,

This appears to be fixed in the Orcas release, but you might want to
verify this yourself (presumably in your real application rather than
WordPad). FWIW, in Orcas B1 that code is now:

// page successfully started, so now render the page
OnPrint(&dcPrint, &printInfo);
if ((nStep > 0) && // pages are printed in ascending order
	(nEndPage > printInfo.GetMaxPage() + nStep)) // out off pages
{
	// OnPrint may have set the last page
	// because the end of the document was reached.
	// The loop must not continue with the next iteration.
	nEndPage = printInfo.GetMaxPage() + nStep; 
}

Dave
0
davidl7375 (2060)
6/3/2007 5:48:18 PM
Reply:

Similar Artilces:

printing in grayscale
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I am brand new to the Mac and am having some difficulties with printing on my HP Officejet 7110 All in One machine. Specifically, the color printheads do not work and I was easily able to tell the printer to print only in black, or grayscale, when on my pc. In fact, there was an option in print preferences and the printer could be set up so it did the same each time I wanted to print something. For the life of me, I cannot figure out how to get it to print just black by using the Mac and with the Office for ...

Print ascending number on multiple printed cpoies
I am using Excel to print labels on a Thermal label printer (a roll of labels). If I print out say 10 copies I want each label to print out in a certain cell the copy number starting from 1 on the first label to 10 on the tenth label. How can I do this? -- cbwood ------------------------------------------------------------------------ cbwood's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23735 View this thread: http://www.excelforum.com/showthread.php?threadid=374086 ...

How Do I Print Customer Receipt from GP
I have a very strong prospect who wants to close deal on GP 5-user AM Licence but wants to raise Official Receipt from the system when customers pay.This is a critical requirement. Does anyone know who to do this with Bank Reconciliation or Receivables Management? Besides, has anyone try it in Crystal and could you share your experience with me on it.? Note: Please do not suggest buying Cashbook Management instead of Bank Reconciliation because it does not offer the ability to receive payment in the SOP or Invoice window and the customer wants its Sales People to raise invoice and rece...

namespaces and protected static members VC .NET bug?
I found bug when use namespaces in mfc application. When I wrote DECLARE_MESSAGE_MAP/BEGIN_MESSAGE_MAP in base (CDialog-derived) class A and in class B : public A (A and B in different namespaces). I narrowed this problem to simple peace of code: class A { protected: static int f; static int *p; public: A() {} ~A() {} }; int A::f = 1; int *A::p = NULL; namespace some { class A : public ::A { static int f; static int *p; public: A() {} ~A() {} }; int A::f = 2; int *A::p = &::A::f; // this line produces error } This code does not work, VC compiller said: error C2248...

Not Print Last Page of a Report
Depending on a value on form, I want to not the last page of a report. Using an event procedure of the report , is there a way to code so the last page does not print? I use the Report Open event to perform several other procedure based on the value of the form. I just can not figure out how to stop the last page from printing. Thanks for any help, Lamar Lamar wrote: >Depending on a value on form, I want to not the last page of a report. >Using an event procedure of the report , is there a way to code so the last >page does not print? I use the Report Open event to perfo...

Transactions By Category Report Bug (Money 2005)
All, I'm experiencing a problem that I can't seem to work around and I hope somebody can help me out. I ran the transaction by category report and selected category A. I then went to the category setup screen and moved category A into B. I then went back to the transactions by category report and this time it won't open. Instead, it acts like it's going to open, but then immediately reverts back to the report menu screen. I'm pretty sure it's doing that because the last selected category the report ran was for category A and that category doesn't exist anymore...

MFC Resource-Chaining Breaking in inproc ATL COM Servers
This is a multi-part message in MIME format. ------=_NextPart_000_001E_01C34AEF.7FD8CE20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable My problem is basically that resource-chaining appears sometimes to = break when I have an inproc MFC COM object (using ATL for the COM = stuff), which itself loads a 2nd inproc MFC COM object (also using ATL = for the COM stuff), and the first COM object is loaded by an MFC EXE. = The 2 DLL's and the EXE all link to the same DLL. All DLLs are coded to be MFC Extension DLL's. Below is a more d...

excel 03 to 07 printing
running trial version. save 03 workbook as 07. 03 workbook came from new computer with 07 on it. saving 03 as 07 on computer that is running 07 trial. now either version will print nothing--page is blank. On Wed, 9 Jan 2008 15:22:36 -0800, harleyman <harleyman@discussions.microsoft.com> wrote: >running trial version. >save 03 workbook as 07. >03 workbook came from new computer with 07 on it. >saving 03 as 07 on computer that is running 07 trial. >now either version will print nothing--page is blank. Please repost your question in an Excel newsgroup. The webpage can be c...

change caption of page
I would like to change the caption of a page by using VBA. I have read many articles about changing the color, but not the actual caption. Can anyone help with this? TIA, Lee -- Message posted via http://www.accessmonster.com I assume when you say page you mean Form. If so try Me.Caption = "whatever" 'Current form Forms![FormName].Caption = "whatever" 'to change another form's caption -- Hope this helps, Daniel P "cableguy47905 via AccessMonster.com" wrote: > I would like to change the caption of a page by using VBA. I have read ma...

filter for work in date range
Hello, I would like to filter for tasks that have work days during a date range in the gant view. eg. I do not want to see a task if it is split during the date range and has no work days assigned. is this possible thanks! The split one is difficult. You can only determine if a task has work on a particular day in a Usage View. There isn't a filter for work on a particular day, so I suspect you may need a VBA solution. -- Rod Gill Microsoft MVP for Project - http://www.project-systems.co.nz Author of the only book on Project VBA, see: http://www.projectvbabook.co...

BUG? Outlook 2003 Not Responding
Hi all, I'm currently running Outlook 2003 (11.5608.5606) along with Active Sync 3.7 (Build 3083). I have the *Hide When Minimized* option set Outlook (thanks MS!) Since my upgrade, I've noticed the following behaviors: When my pocket-pc is disconnected/off: If I *minimize* Outlook, it hides itself in the system tray, and can (almost) always be restored. If I *close* Outlook closes, and can be restarted. When my pocket-pc is connected/on: If I *minimize* Outlook, it hides itself in the system tray, and can (almost) always be restored. However if I *close* Outlook Outlook minimizes ...

Way to cancel loading of home page if security privilege errors
A user accidentally chose the wrong role (ex. HR) and doesn't have security privileges to HR. She got a series of security privilege errors and the system hung. We tried temporarily giving her rights to what she needed just to get the home page loaded so she could change her role. There should be a way to cancel the load of the home page and to change your role without getting into the home page. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button ...

Calendar printing monthly view
Example - printing the monthly view of August - in the upper right the program prints the month you are viewing as well as the next month. I would like for this printout to show the prior month and the next month - if I print the monthly view for August the upper right should show July and September - NOT August and September. I've yet to find anywhere in Outlook to make this change ...

print invoices to pdf
Hi, Does anyone know of a way to print a batch of invoices to separate pdf files (one invoice should create one pdf file) and have the invoice number as the pdf file name? Or is there an option to specify the file names one by one? Would that be a customization or a third party product? Any advice is very much appreciated. Thank you. Peter You can check eMailer Manager from Binary Stream (http://www.binarystream.com/emailer_manager.asp) and Electronic Document Delivery for Business Portal. EDD is a Microsoft tool you can find on the Dynamics web site. -- Charles Allen, MVP ...

OL2003 Signature Bug?
I have four pop-mail accounts in a single profile. I'll call the Accounts A, B, C, and D. "A" is the default account. In OL2003, you are able to create a different signature for each account. I have created "New Message" and "Reply-to/Forward Message" signatures for two of the accounts (A and C). When creating a new message, the signature for A appears correctly by default. If I switch the "send from" account to C, the signature for C replaces the signature for A. This is expected. If instead, I switch to accounts B or D, the signature...

Page Number Problem It resets to 1 of 1
I have Word 2007, Vista. I have added a page number (built in format, at position, x of y) in a header first page (different), it is in a table. The page number (x of y) is also in the footer (which is blank on the 'different' first page). The footer page number works fine. If i put the page number in the rest of the page headers, it works fine. Problem - the page number in the first page header automatically updates as pages are added, deleted. But, when the docx is closed and then reopened it resets the x of y in the first page header to 1 of 1. If i click in the...

Money 2006 net worth bug
I have noticed that one of my net worth over time favorite reports refuses to load. If I watch the CPU, it appears that $ is in an infinite loop with the load bouncing back and forth between 50 and 80%. But the really amusing thing is this: during the loop if I select "custom date", change either the start or stop date (move either to a new date, or just touch one - change a date and move it back) and select the APPLY button, the load will converge. If you select the OK button, the load will not converge. I have saved a net worth report that converges and attempted to reload...

Timecard should print in right order
The timecard report in Business Portal HRMSS prints the second week of the pay period first, followed by the first week of the pay period. The days are properly in ascending order, but it is very confusing to have the second week show up before the first (weeks in descending order). ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based New...

Linking to internal visio pages
Hi all, I've been trying to figure out a way to link to an specific page that is imbedded in a visio file saved as a web page. For example: I have a visio file that consists of 12 pages accessed by tabs along the bottom of the screen. When I export this file as a webpage, access to the individual pages appears as a pull down menu on the left side of the page. The file is given an address, but not the individual pages, so if I create a link to the visio file it always defaults to the first page. Is there anyway to link to specific pages within the file? Thanks in advance, Tim ...

In Line changes not printing in line
When I have my changes displayed in line and I select Print, the Print Preview shows the changes in line, but the actual printed document shows them as bubbles to the right. Any idea what I'm doing wrong? Bubbles as in symbols? Are they document notes? If they are document notes you need to deselect print notes. They can be formatting marks, check display under Word options from your print dialogue box. Hope that helps :) "Robert_L_Ross" wrote: > When I have my changes displayed in line and I select Print, the Print > Preview shows the changes i...

Is this a bug or not?
I replied to an email that was archived in Outlook 2007. The 'sent' copy was placed in the archived sent folder instead of the one in my personal folders. Is this normal or a bug? Is there anyway that I configure responses to archived 'mails to be put in the current sent folder? TIA. Cheers, Guy ** Stress - the condition brought about by having to ** resist the temptation to beat the living daylights ** out of someone who richly deserves it. "Dr Teeth" wrote in message news:db8si3lpuejhnpm3luacpu2rkkaef66stt@4ax.com... > I replied to an email that was archiv...

Access 2007: bug? quick filter list is sometimes empty
Access 2007 has a great new feature which allows to easily filter by selecting different values from a drop down box on top of each column. However, sometimes the list of values simply is EMPTY in some columns. It seems that this has to do with the complexity of the underlying query. Does anyone know how to circumvent this? Or is it simply a bug? Kind regards Georg When the list of unique choices gets too big they don't show. You have some control over this office button/access options/current database/Filter lookup options (look at bottom of screen). It takes tim...

Page Numbering #18
I need the automatic page numbering to start off as double numbers, ie 01,02,03,04,05 etc. Is this possible? Insert, section, scroll to the bottom of the Number Format drop down. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "sophie" <sophie@discussions.microsoft.com> wrote in message news:49CFD919-C460-4F51-B167-0E5B32FBC9A5@microsoft.com... >I need the automatic page numbering to start off as double numbers, ie > 01,02,03,04,05 etc. Is this possible? ...

Refer to a named range
Hi XL2003 I am having trouble using a named range in a macro, even after refering the Help. The named range lives in the active workbook on another sheet. My code is this: Private Sub Worksheet_Activate() With [CompNames] Set c = .Find(Range("A1")) If Not c Is Nothing Then A = Sheets("Names").Cells(c.Row, 3) End With If ActiveSheet.Name <> A Then ActiveSheet.Name = A End Sub You will see that I have had to resort to using [ ] around the named range, which is the only way I could get the code to run. I tried Range("...

Bug in queue an activity association
When I see, for example, in my work queue, an email, and I make the following steps: 1. Open Email in New Window (from work item queue) 2. I delete email (not queue, just Email) 3. When I return to queue, even if I refresh, email is still there in my queue. 4. When I try to open email again from queue, I get error because record is not there anymore. Invistigatin further, I saw that ActivityParty and ActivityPointer tables doesn't have activityid, but queueitembase table has not deleted reference. This seems an error, and as workaround, I need to execute SQL directly (which btw is n...