Home General

Custom print preview

edited July 2001 in General
Thank you so much for breaking my code in RB6. I've been using the
same custom print preview since December of 1999, with only minor
rewrites. Now I can't even get it to compile.

What was I doing? Overriding TppPrintPreview, then registering my new
custom previewer. Of course now I can't refer to ppViewer1,
spbPreviewClose, and who knows what else.

So what am I supposed to do now?

It wouldn't be so bad if you had bothered to document
TppCustomPreviewer, Viewer, etc.

Any other "gotchas" in RB6?
++++
Bill Sorensen, Programmer/Analyst, ASI/EDI Inc.
(opinions are mine alone)
bsorensen@asicentral.com
www.asiedi.com

Comments

  • edited July 2001
    Well, I've managed to figure out some of it on my own, through trial,
    error, and reading the source code.

    1. Create a class that descends from TppPreview. (This is simpler
    than descending from TppCustomPreview.)

    2. Override methods such as BeforePreview and KeyDown.

    3. Parent will be the preview form, generally (check before cast).

    4. Viewer and Report are the other properties you may want to access.
    Note that until you call inherited in BeforePreview, Report is nil.

    5. Call PerformPreviewAction as desired. Note that this may attempt
    to set the focus (a bad idea when the form isn't visible).

    This is a particularly poor design, for several reasons. First,
    clicking any of the toolbar controls will change the focus, so KeyDown
    will no longer be called. Second, it's completely non-visual; see the
    wonderful code in procedure TppPreview.CreateToolbarControls
    (ppPreview.pas). I'd rather write Swing without JBuilder.

    Looks like somebody read a book on design patterns and decided to
    refactor the preview code. Next time, consider things like "backwards
    compatibility" and "clear documentation."

    If it ain't broke, don't refactor it.

    On Mon, 30 Jul 2001 11:00:17 -0500, William Sorensen
  • edited July 2001
    I would descend from TppCustomPrevew just like TppPreview does. You should
    then get access to the KeyDown event. We apologize for breaking your code.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited July 2001
    In article , William
  • edited July 2001
    The TppPreview class was created for our default preview, and yes, the
    controls are created in code. The advantage is that this previewer is
    modifiable both in the report designer and on the viewer. However, it
    doesn't have to be created through code. The replacable form approach, which
    has been in the product for a long time, should still working as it always
    did. The problem with the form based approach is that you can't change the
    previewer in the report designer. Run the Tutorials Complete project in the
    RB installation for an example of the old way of creating a custom
    previewer- it should still work. You don't have to create everything in
    code:)

    The keydown isn't firing, hmm...we'll have to look into this. Thankyou for
    the feedback.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited July 2001
    In article <8EAE82296ACCD311A039005004E0CAC004705C@DMSERVER>, Jim Bennett (Digital Metaphors) wrote:


    Thats not the problem. The problem is that I used something like this:
    ----
    { DruckVorschau }
    if FForm is TppPrintPreview then begin
    if not TppPrintPreView(FForm).ppViewer1.ScrollBox.VertScrollBar.Visible then begin
    if (Key = VK_NEXT) and (Shift = []) then begin
    TppPrintPreView(FForm).ppViewer1.NextPage;
    exit;
    end;
    if (Key = VK_PRIOR) and (Shift = []) then begin
    TppPrintPreView(FForm).ppViewer1.PriorPage;
    exit;
    end;
    if (Key = VK_HOME) and (Shift = []) then begin
    TppPrintPreView(FForm).ppViewer1.FirstPage;
    exit;
    end;
    if (Key = VK_END) and (Shift = []) then begin
    TppPrintPreView(FForm).ppViewer1.LastPage;
    exit;
    end;
    end;
    if Shift = [ssAlt] then begin
    if (Key = VK_ADD ) and (TppPrintPreView(FForm).ppViewer1.ZoomPercentage < 150) then begin
    TppPrintPreView(FForm).ppViewer1.ZoomPercentage := TppPrintPreView(FForm).ppViewer1.ZoomPercentage +
    1;
    TppPrintPreView(FForm).ppViewer1.OnPageChange(Nil);
    Exit;
    end;
    if (Key = VK_SUBTRACT )and (TppPrintPreView(FForm).ppViewer1.ZoomPercentage > 0)then begin
    TppPrintPreView(FForm).ppViewer1.ZoomPercentage := TppPrintPreView(FForm).ppViewer1.ZoomPercentage -
    1;
    TppPrintPreView(FForm).ppViewer1.OnPageChange(Nil);
    exit;
    end;
    if (Key = Ord('D')) or (Key = Ord('d')) then begin
    TppPrintPreView(FForm).ppViewer1.Print;
    exit;
    end;
    end;
    { Ctrl-P für Drucken }
    if ((Key = Ord('P')) or (Key = Ord('p'))) and (Shift = [ssCtrl]) then begin
    TppPrintPreView(FForm).ppViewer1.Print;
    exit;
    end;

    end;

    ----
    and TppPrintPreview.ppViewer1 is now not longer available or much more complicate.

    Thanks for support.

    Gruß aus den Bergen
    Günter
  • edited August 2001
    Sorry, for the delay- I overlooked this post. Viewer is a public property
    of the TppCustomPreview class.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.