CHtmlView and Printing

Hi Everyone,

The CHtmlView is giving me alot of head aches.  Here is what I am doing.  I
am opening an XML file (being formatted using XLST) in a hidden CHtmlView
and printing it.

Here is how the process goes:
1. I create the XML file on the fly.
2. load the XML file in to CHtmlView.
3. Once loaded I tell it to print the resulting HTML page.
4, I need to delete XML file after the printing is done. (this is the
problem).

I can't figure out how to find out when the CHtmlView is done printing.
CHtmlView::OnFilePrint is asynchronous.  And CHtmlView doesn't tell me that
it is currently printing.
(Note: Navigate methods are also asynchronous but you can figure out that
it's not done loading using CHtmlView::GetBusy().)

Here is the code I have so far

      ASSERT(m_pPrintView && m_pPrintView->GetSafeHwnd());

      CString Filename;
      char Buffer[200];
      GetCurrentDirectory(200,Buffer);
      Filename.Format("%sReports\\%ld.xml",Buffer,GetTickCount());

        //generates the XML Document
      LSActivityPrinter Printer(GetDocument()->GetActivity(),this);

Printer.PrinterEditor(Filename,Dlg.m_PrintClues,Dlg.m_PrintFact,Dlg.m_PrintC
ode);

        //load the XML file
      m_pPrintView->Navigate2(Filename);
       //wait while it is loading the XML file
      while (m_pPrintView->GetBusy())
      {
            //pump messages while waiting.
         ((CLSEditorApp *)AfxGetApp())->Yeild();
      }
        //tell it to print the HTML File
      m_pPrintView->OnFilePrint();

      while (m_pPrintView->GetBusy())
      {
         ((CLSEditorApp *)AfxGetApp())->Yeild();
      }

        //delete the XML and any supporting Jpgs
      Printer.Cleanup();


AliR.


0
AliR3470 (3235)
5/1/2006 4:25:30 PM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1631 Views

Similar Articles

[PageSpeed] 39

Hi,

Currently I am looking for somebody who could help you on it. We will reply 
here with more information as soon as possible. 
If you have any more concerns on it, please feel free to post here.


Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-phuang (38)
5/2/2006 7:21:07 AM
Hi Ali,

I have consulted this issue with our product team, it seems there isn't any 
way to get the notification when a CHtmlView is finished printing. I am 
afraid you have to use your current workaround.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so 
that others may learn and benefit from your issue. 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-garych (605)
5/4/2006 2:24:09 AM
Thanks for trying Gary.

AliR.

""Gary Chang[MSFT]"" <v-garych@online.microsoft.com> wrote in message
news:s0dAaHybGHA.4488@TK2MSFTNGXA01.phx.gbl...
> Hi Ali,
>
> I have consulted this issue with our product team, it seems there isn't
any
> way to get the notification when a CHtmlView is finished printing. I am
> afraid you have to use your current workaround.
>
> Thanks for your understanding.
>
> Best regards,
>
> Gary Chang
> Microsoft Online Community Support
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>


0
AliR3470 (3235)
5/4/2006 3:02:37 PM
You are welcome, Ali. :)

Have a nice day!

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so 
that others may learn and benefit from your issue. 
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

0
v-garych (605)
5/5/2006 3:32:04 AM
Reply:

Similar Artilces:

Check printing error
I was in the process of printing my check batch for the week. I went to purchasing, print checks, selected my batch, and pushed print. Usually a screen will come up that then tells me to push print one more time, but this screen never appeared! If I repeat my steps, the batch no longer appears in the window. If I go to purchasing, post checks, and select that batch, I can see the batch with status "Check Printing". If I try to select the batch, it says" This batch is being edited by another user. Please try later." If I go to transactions, purchasing, batches, again...

CHtmlView and OnChar
I created an SDI app with CHtmlView as my view class, but cannot recieve WM_CHAR messages, or any keyboard or mouse messages for that matter. I tried routing them thru both the View and Main Frame class but it still doesn't work. Could someone please tell me if there is a way to use these messages with CHtmlView. Thanks in advance. Trap WM_CHAR in PreTranslate method. This particuler ActiveX control that is hosted in CHTMLView does not work as you expect with PreTranslateMessage or trapping WM_CHAR etc. There are couple of ways to do this. One is to automate the control and li...

Grayed-out printing on report (preview and print)
I have a new user with a Dell Pentium 4, XP, Dell all-in-one 922 printer. When she previews or prints any report from my program, it shows as though there were a "greyed-out" option in effect, and the width of the report is chopped on both sides. She says that other printing (Word, Quicken reports) does not do this. She is using Access Runtime 2002. Does anyone have any thoughts on where to look for the source of the problem? Is it a function that is normally controlled by the printer driver? -- Gordon Jones The default margins may be wider than your report. Likewise she...

CHtmlView
We have a CHtmlView with two fames in a MFC application. <html> <frameset cols="30%,70%"> <frame name="menu" ...> <frame name="detail" ...> </frameset> </html> on the menu frame there are some links. when you click the link, we use Navigate2() to request a .jsp page and put it in the detail frame. I know CHtmlView::GetReadyState()==READYSTATE_COMPLETE means the view is at ready state. I want to know when the detail frame is ready. I tried GetReadyState(). It didn't work. It always return me READYSTATE_COMPLETE ...

Printing #24
I have an org chart I am trying to print. When I go to print preview I only get a section of the org chart. Anyidea how I can print the whole thing and just the one section? Have you considered your printer driver may need updating? Go to the manufacturer's web site and look around for an updated driver for your model printer. It is wise to completely remove the driver before you install/re-install Bruce Sanderson's Windows Web How to clean up printer drivers http://members.shaw.ca/bsanders/CleanPrinterDrivers.htm If the printer driver is okay, think about your graphics driver...

Printing a table of organization
I completed a Table of Organization and when I try to print it on an HP PCS 2355, I get a blank sheet with nothing printed. I've made ajsutments in the print section, but again not able to print. Which version of Visio and have you downloaded the latest service pack for Visio. Also, are you running with the latest printer drivers for your printer. John... Visio MVP Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm Need VBA examples? http://www.mvps.org/visio/VBA.htm Common Visio Questions http://www.mvps.org/visio/common_questions.htm Visio Wishlist http://w...

Broadcast Printing
Is there a way to print a single item (Excel Spreadsheet to multiple computers on a network (broadcast printing) so that when I create a spreadsheet I do not have to send to multiple printers one at a time. This is very time consuming. I know there are aftermarket products that do this but I was told you could do with the Office Suite itself. Thanks for your replies. You could record a macro when you change the printer, print, change the print, print, change the printer, print and on and on and on. Then just rerun this macro when you want to print to those printers. kikboxr777 wrote:...

Script Fonts are not registering when I print
When I print Kunstler Script (true type), part of the text is missing, although I can see the text is completely there in the layout of the text box. This is publisher 2000 and I am printing to an epson printer. I would appreciate any assistance with this problem. PUB2000: Some Fonts in the Font List May Not be Used in the Publication http://support.microsoft.com/default.aspx?scid=kb;en-us;218639&Product=pub2000 Have you installed all the service packs? PUB2000: Enhancements and Bug Fixes in SR-1 http://support.microsoft.com/default.aspx?scid=kb;en-us;255526&Product=pub2000 See if...

How do I print labels from an existing excel spreadsheet?
I have an address directory set up as an excel spreadsheet with each line of the address in a new column. I have seen people print labels directly from a spreadsheet like this, but I don't know the steps. Any help out there? Use Word's mail merge facility, with the Excel file as the data source: Mail merge Excel to Word: a.. http://www.mvps.org/dmcritchie/excel/mailmerg.htm b.. http://www.mvps.org/word/FAQs/MailMerge -- David Biddulph "bnten" <bnten@discussions.microsoft.com> wrote in message news:E05FAD13-0136-4769-8419-93D628A37D1A@microsoft....

Publisher 2007 print dialog preview
Is there a way to turn off the preview in the Print Dialog box? I've tried selecting the "Show how to insert paper" but it always defaults back to "Show paper after printing". Is there a particular reason you don't want the preview? You can setup your printer before you create your publication, then when you are ready to print, click the icon on the toolbar. The preview dialogue will not show. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "rharper1234" <rharper1234@discussions.microsoft....

Duplex Printing
I use Windows7, Office 2007, and an HP 2605dn printer. When printing in Publisher I have the option to print on both sides. In Word (and in pdf files) I do not have that option, either in the main "print" box or in the "finishing" box in the "properties" section. The driver is listed as the same for both. How do I fix it so I can print on both sides in any application? It is a printer properties thing. Make sure that you have the lastest printer driver installed. -- Hope this helps. Please reply to the newsgroup unless you wish to avail ...

unable to print E-mail
I am running outlook 2003 and I keep getting an error when I try to print any e-mail from outlook. If i save the e- mail to my docs and then print from there everything is okay. And that error would be...??? Also describe your method of printing as you can do it in many many ways. -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slipstreamed with Service Pack 1 ----- "Dave G" <anonymous@discussions.microsoft.com> wrote in message news:3bcd01c4ac33$688235d0$a501280a@phx.gbl... >I am ...

Workbook Defaults to Printing 33 Copies
I have a form that I reuse every week, and all of a sudden it's defaulting to printing 33 copies. Is there any way to change it back so that it defaults to print only one copy, like all my other workbooks?? Thanks! -- Lori I believe it is File - Print - click properties button in upper right - click the advanced tab - click on Paper/Output and change it back to one. OK/Save changes. "Lori Keener" wrote: > I have a form that I reuse every week, and all of a sudden it's defaulting to > printing 33 copies. Is there any way to change it back so that it defaults ...

Printing labels
I have an Excel spreadsheet that uses a query to get info from the database, this info is held in a list, each item is a replenishment available to be done. I want to be able to re-produce this list on a separate sheet but 4 at a time so they can be printed on sticky labels. Using a straight forward cell reference I have the fist 4 items but I can't figure out how to move the cell reference down by 4 so as to print the next 4. Am I going about it the long way? The list will change in length so I'll need to check and stop at the end of the list. Ideas or help appreciated. Dea...

Printing to pdf loses graphic background
I have created a page that is to be the back cover of a publication. It was originally created in Publisher 2003 but I am now working in 2007. The background is a scan of a satellite map and there are several text boxes and "autoshapes" with text scattered about the page. When I do print to a PDF file, the background graphic does not print. I get a message stating "Publisher can not complete the operation" But it does well with less complex pages. The pack and go file is 291,076 in size. That does not print to PDF either. Only the text and autoshapes print. I am ...

Printing Column Headings
Hi, How do I go about printing the column headings on each new page of my spreadsheet? Thank you In the main menu: File - Page Setup -Sheet - Rows to repeat at top HTH Mike >-----Original Message----- >Hi, > >How do I go about printing the column headings on each >new page of my spreadsheet? > >Thank you >. > Hi Martin, See my web page http://www.mvps.org/dmcritchie/excel/freeze.htm File, Page Setup, Sheet Rows to Repeat at top: $1:$1 --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dm...

Printing Statements?
I'm a new user. Printing my first statements. How Do I get rid of the Minimum Payment field or change the amount to show the current balance? -- JD Hi JD - Thanks for your note. In order to modify the account statement, you will need to modify the XML file. The file name and path can be found in Store Operations Administrator, in the Configuration dialog, Templates tab. Typically, the file is Statement.XML and is located in c:\program files\microsoft retail management system\store operations\receipt templates folder. Once you find the file used for your account statements, locate...

printing Other User's calendar
I user Outlook XP and I have trouble when I need to print Other User's calendar in Month Mode. Each time I print a calendar that belongs to another user, for exaple John Doe, in a Monthly view with a 2Pages/Month stye layout, the footer, where it display the 'User Name' does not display 'John Doe' but instead Danumurthi Mahendra. I found out other than that, that it works perfectly fine with other types of layout. I've tried in vain to fix this bug but it just persisted. ...

Painting of CHtmlView !!!
Hello All I am showing dialog when clicked on link of HTML page navigated inside CHtmlView. After closing dialog, the browser( CHtmlView ) does not paint itself properly. I did everything to solve this problem including Send Paint message, InvalidateRect, WM_ERASEBKGND, UpdateWindow and RedrawWindow. But all solutions did not help me. So MFC Gurus, Please help me to solve this problem of painting of CHtmlView. ...

Why is the Print Titles option in Page Setup:Sheet greyed out?
I am trying to print the column labels on each of a 10 page list. When I go to Page Setup, then the Sheet tab, the items under Print Titles are greyed out. i.e. I can't enter a row for the "Rows to Repeat at Top" option. Anyone know why? Can't find anything in the help file. Thanks, Tim timz Wrote: > I am trying to print the column labels on each of a 10 page list. When > go > to Page Setup, then the Sheet tab, the items under Print Titles ar > greyed > out. i.e. I can't enter a row for the "Rows to Repeat at Top" option. > > Anyone...

Check Stub printing Unpaid Invoices
Please confirm: Invoices with credit memos print on Check Stubs even though they have not been selected to be paid on the check. Is this correct? If you uncheck Print Previously Applied Documents, no credit memos print period. Is there away around this? My client wants only invoices with their credit memos they have selected to print on the check (the check total = the total of the invoices and credit memos). The ones not selected (including the applied credit memos) would be available for the next check run. Any help is greatly appreciated. ...

Outlook doesn't print images
I have a rule created to print emails from a certain sender. The emails will always contain an image. Outlook 2003 is printing the email message, but only prints a link to the image, not the image itself. If I reprint the message manually, the image WILL print. I have set Outlook to download all messages, no restrictions. Previously, only emails from safe senders had the images downloaded, but even loosening the restrictions has not solved the problem. How can I make Outlook 2003 print the emails automatically as they arrive AND include the image? ...

CHTMLView help needed
I have a CHTMLView and I want to save the output from it as a bitmap (or some other image type) file. Does anyone know how to render the content of the view to an image file (IE5.5 and up)? The normal standard Windows GDI based approach doesn't seem to work because it only gets the area of the view that is visible and includes the view's scroll bars in the output. Is there away to get cleaner output rendered to an impage file that doesn't have the scroll bars and shows the whole content, not just what is currently visible onscreen? ---------------------------- I know one of you ...

How to force CHtmlView refress()?
Hi, I have to use CHtmlView for browsing the html page with dialog. I have tow dialogs: First dialogs view the html page with the images, when I click on one image, this will popup up second dialog(a new dialog) to list details about this image, I have some processing with the second dialog, when it finished I will close the dialog and go to first dialog again, before (or also for after) I close the second dialog I do refresh for with the page on first dialog by calling m_myHtmlControl.refresh() or also for m_myHtmlControl.refresh2(3,NULL,NULL.NULL) ; But this cause system error. How...

can't see photos in my document but they print
Somehow I've made the photos in my MS Publisher document disappear but they are there when I print. I need to see them as I edit and rework pages. What did I do wrong? How can I fix it. Thanks. Ron View, Pictures, detailed display... If this does not solve the issue, then your video/graphics driver needs upgrading. Do this, slide the acceleration down on your adapter: Control panel, Display folder, settings tab, advanced button, troubleshoot tab. If your images appear when you slide the acceleration down, then go to the manufacturer's web site of your graphics card and u...