Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Report viewer cancel button is disabled

edited April 2003 in General
My Report viewer cancel button is disabled. Any ideas why?

Running RB Ent 7.02

PAt Bell

Comments

  • edited April 2003
    Pat,

    When is the cancel button disabled? Please give me the steps to take which
    would allow me to see the error. By default the cancel button is disabled
    when there is nothing to cancel.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2003
    Good point - its actually a designer component, when I go to the
    preview screen the [Close/Cancel] button is disabled and just
    shows [Cancel] (greyed out).

    I need it to show [Close] as it would if I didn't use the
    designer.
  • edited April 2003
    Pat,

    You will need to create a descendent of the TppPreview class and override
    the PrintStateChangeEvent. Then you can adjust that method to enable the
    cancel/close button as you need it. You will need to set the caption of the
    CancelButton and change the CancelButton.Enabled to true. I created an
    example that does this for you. If you would like to use this descendent in
    your project, simply add the MyPreview.pas file to your project and rebuild.


    http://www.digital-metaphors.com/tips/PreviewCloseButtonEnabled.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2003
    Thanks that works as far as [Cancel] is concerned but since [Cancel] is only
    relevant when processing, it was the [Close] button I really needed - sorry if
    I didn't explain myself properly. How do I make it say [Close] and actually
    close the preview? Like it does if not using the designer?

  • edited April 2003
    In article <3e9ef950$1@dm500.>, Nico Cizik (Digital Metaphors) wrote:
    I should say the button doesn't actually do anything. Not only does it just
    say [Cancel] since as far as debug goes it thinks viewer=busy and
    viewer=designviewer (even if I actually click the tab for preview) but even if
    I override those checks force it to pploadstr(ppmsgclose) to make it say
    [Close] it still does nothing.

    .> Pat,
  • edited April 2003
    Hi Pat,

    Here is a link for an updated version of the example I gave you before.
    This example enables the close button in the previewer as well as the
    designer preview window. Enjoy :).

    http://www.digital-metaphors.com/tips/PreviewCloseButtonEnabled.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2003
    Thats the one I am using and it doesn't enable the close button as you
    claim. Whilst it shows [Close] as the button caption, the button doesn't
    close the preview, it does nothing.

  • edited April 2003
    Correction on my previous email - clicking [Close] generates an AV on the
    line Form1.ppdesigner1.close (doh!) - when I correct(?) it for my own
    designer component name to fmMain.ppdesigner1.close... _then_ it does
    nothing.

    Have you tried this code yourself?


  • edited April 2003
    I am sorry if I sounded curt before - but I have several users moaning
    about the [Close] button not working even though the [X] close form works
    fine.

    Of course you have tried it, your demo project works fine. In fact if I
    use a ppdesigner that is on the same form as my ppreport and set the
    MyPreview close action to fmCurrent.ppdesigner1.close. It works. But this
    means MyPreview is only valid for one report.

    I therefore placed one ppdesigner in fmMain. And set the close action in
    MyPreview to fmMain.ppdesigner1.close; This previews fine (I set the
    report name (fmCurrent.ppreport for example) each time I use it) but
    close does nothing... No AV but not closing.


  • edited April 2003
    Pat,

    The close button is only meant to be used with the print preview dialog. It
    was never a feature of the Designer preview window and will therefore have
    to be added as a custom feature of your own. One way you could try to
    accomplish this would be to use my example as a starting point and create a
    form ancestor containing a function that will return the TppDesigner object
    on the form. In your application when you show one of your forms, set a
    global variable to be an instance of the form as the ancestor form type so
    that you can call this function. The place where you will call this
    function is inside the preview replacement class to get the current designer
    component. This way you will be able to create as many descendent forms as
    you want and close them using your newly created close button, and also be
    able to use more than one designer component.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2003
    Even though I can use a common single designer component for all my reports -
    Since I can't even figure out why form1.ppdesignerl.close works but not
    fmMain.ppdesigner1.close then I doubt my abilities are up to following the
    advice you give below.

    Since a print preview page is available in the designer, it seems odd that it
    should not have a simple close button. Perhaps I am using the designer in an
    unusual way - ie giving the end-user the opportunity to change the layout of
    their previewed document - I guess other developers must be blessed with more
    forgiving or perhaps more competent users who use it for its more powerful
    functions.


  • edited May 2003
    Hi Pat,

    Here is another example for you to look at. This example sets up the
    archetecture you will need to implement what I described in my last post.
    This example sets up only the ability to register one descendent class but
    it is clearly marked where you would have to add code to support multiple
    designers. The key item to look at in this example is that you do not need
    to know the form classtype in order to get the instances of the designer.

    http://www.digital-metaphors.com/tips/PreviewCloseButtonEnabled.zip

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.