Hide some pages when I do a print preview

The report I use, has 9 pages when I prepare it.

But when I use the next code, the pages 3 and 5 are visible when watching the print preview. Accordint to me that pages should be NOT visbile:
  frm_ReportPreview := Tfrm_ReportPreview.Create(Application);
  frm_Reports.fstrp_Test.Preview := frm_ReportPreview.frPreview;

  if not frm_Reports.fstrp_Test.PrepareReport then
    ShowMessage('Not prepared!!!');

  frm_Reports.fstrp_Test.EMFPages.Pages[3].Visible := False;
  frm_Reports.fstrp_Test.EMFPages.Pages[5].Visible := False;

  frm_Reports.fstrp_Test.ShowPreparedReport;

  frm_ReportPreview.ShowModal;

How can I hide some pages when I do a print preview?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 10:18PM
    Hi IMHO you can't
    you can hide designpages but not produced pages.
    regards ;)
  • edited 10:18PM
    I didn't try but maybe works:

    Don't call ShowReport directly, instead call PrepareReport;
    Than this code: EMFPages[Index].Visible:=False;
    Than ShowPreparedReport;

    Regards:Alex
  • edited 10:18PM
    Hi!

    It's me again. I tried and the working code is:

    R.PrepareReport;
    R.EMFPages.Delete(DesiredPageIndex);
    R.ShowPreparedReport;

    Regards:Alex
  • edited 10:18PM
    Thnx, it works!
  • edited 10:18PM
    Hi,

    Other way to hide a page is to set the visible := False before to prepared the report.

    See in your example:
    frm_ReportPreview := Tfrm_ReportPreview.Create(Application);
     frm_Reports.fstrp_Test.Preview := frm_ReportPreview.frPreview;
    
    // ********** Correct position  *************
     frm_Reports.fstrp_Test.EMFPages.Pages[3].Visible := False;
     frm_Reports.fstrp_Test.EMFPages.Pages[5].Visible := False;
    
     if not frm_Reports.fstrp_Test.PrepareReport then
       ShowMessage('Not prepared!!!');
    
    // ********** InCorrect position  *************
    // the original position
    // frm_Reports.fstrp_Test.EMFPages.Pages[3].Visible := False;
    // frm_Reports.fstrp_Test.EMFPages.Pages[5].Visible := False;
    
     frm_Reports.fstrp_Test.ShowPreparedReport;
    
     frm_ReportPreview.ShowModal;
    

    Luciano
  • gordkgordk St.Catherines On. Canada.
    edited 10:18PM
    Hi all
    be carefull when deleting emf pages by index number, if you are manipulating pages in the final pass of a 2 pass report due to freespace requirements, you will not know the correct emfpage index value untill after you have previewed the report.
    regards ;)
  • edited 10:18PM
    By the way I'll explain why I need some pages to be hided:

    I think the most programs are not good designed. Because on the printdialog you almost never see the button: print preview.

    I think that is very strange, because the user can there select a few options, for example he can choose to print only a couple of page by entering the page nummers.

    When the user want a preview, he wants exaclty see what the printer will prints. So in my program, I have placed a preview button on the print dialog.

    When the user press the preview button, he sees exactly what the printer will prints and that's why I need to hide some pages.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.