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

Major RB Mystery Solved Canvas Does Not Allow Drawing

edited September 2011 in General
Hello All:

I am running an older version of Reportbuilder 6.03 using Delphi 5. When
my application runs under remote desktop I occasionally get a "Canvas Does
Not Allow Drawing" Error. I could never figure out why it happened. To cure
it I was rebooting the server - the reboot corrected the problem alot of the
time. However, recently rebooting one client's computer did not cure the
"Canvas Does Not Allow Drawing" Error.

After googling this error, I have discovered the problem. The problem is
that the default driver under the Remote Desktop user profile was invalid.
My code assigns a valid print driver to the ppReport component (im not sure
exactly when in the sequence this happens) - but it appears that the older
version of ReportBuilder uses the default windows printer driver for some
functionality.

If I switch the windows default printer driver to a valid printer
driver - the reportbuilder error disappears and all printing is executed
correctly. If I switch the windows printer driver back to the invalid
printer driver the program again produces the "Canvas Does Not Allow
Drawing" Error. This occurs despite the fact that I assign the printer
driver to the valid printer driver in the ppReport1 component. If the
windows default driver in the Remote Desktop session points to an invalid
printer driver, Reportbuilder 6.03 seems to produce that error.

Nard - does this make sense ??? Is this something that should be logged
into the RBWiki ???

I own RB12 and will upgrade my software to RB12 in the next few weeks -
Im hoping per the Wiki that RB12 will eliminate this issue. Thank you very
much. I really love the RB product.

Neil Huhta
Profit Monster Data Systems LLC

Comments

  • edited September 2011

    "Canvas does not allow drawing" is a Delphi exception that indicates an
    invalid handle to a windows device context (Canvas.Handle). This is most
    often caused by the application leaking memory/resources, which is why
    restarting the app or rebooting may resolve the problem. As you mention
    this exception can also be caused by a reference to a invalid driver.

    1. I recommend running the app under a tool that can detect resource/memory
    leaks. FastMM is the memory manager included with the latest Delphi releases
    and it can be configured to debug resource/memory leaks. AQTime is another
    such tool.

    2. RB caches the list of available printers. If drivers are being
    installed/uninstalled while the app is running, you can programmatically
    refresh the list using the following code

    uses
    ppPrintr;

    ppPrinters.Refresh;


    RB 12 has an improved architecture that is designed to give a more specific
    error messages for some printer related issues. I don't know whether it will
    help your specific case or not. If the remote desktop is
    installing/uninstalling drivers then doing the refresh shown above should
    help. If the app is leaking memory/resources, then fixing the leaks should
    help.


    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited September 2011
    Nard:

    There is absolutely not a resource leak here - this is primarily a quirk
    between Windoiws remote desktop services and version 6 and earlier of
    ReportBuilder.

    #1) I routinely use AQTime for leak testing.
    #2) I am not adding a printer driver form my application ever (no need
    to refresh the application).

    I can open a remote desktop session which has an invalid printer driver
    assigned as the default printer (this is the quirk in remote desktop
    services - you should NOT so easily be able to have invalid printer drivers
    this-but it seems to be a common problem in Remote Desktop). Next, I take
    any app with ReportBuilder 6.x and assign a different printer driver and
    then try to print.

    Here is what happens - it appears that Reportbuilder grabs the default
    printer driver to do some processing - but - since the default printer
    driver is not valid - it produces the "Canvas does not allow drawing" error
    .

    Next, I switch the default printer in the windows session to a valid
    printer driver, then re-run the report - same app - same session - and now -
    it prints perfectly.

    I tested this with my big application and I also tested it with a 1 table
    1 form application - same results both applications.

    What my point is - is as follows:

    When running in a Remote session - one should be aware that an invalid
    default printer in the session will cause ANY software trying to get a
    handle to it - to throw the "Canvas Does Not Allow Drawing" error.

    My assertion is that these circumstances suggest that ReportBuilder is
    ignoring my assignment of a specific driver (but only during pre-print
    processing) - and is trying to access the default printer driver during
    pre-printing processing.

    My first question is "Does Reportbuilder 6 do some pre-printing
    processing by grabbing the default printer driver (I suspect yes) ???

    My second question is "Has the current Version 12 of ReportBuilder
    eliminated the use of the default printer driver for pre-printing processing
    (I also suspect yes)???

    I discovered this cause by parousing the MSDN library and newsgroups -
    there seems to be some amount of problems with default printers in Remote
    Desktop.

    I really think you should put a note in the Wiki - when this message
    comes up in remote desktop - suggest that the users test for an invalid
    printer handle by switching the default printer and re-running the report.

    Such a note would have saved me alot of work.

    Neil Huhta



  • edited September 2011

    You might also want to search this newsgroup for messages with subjects
    containing "NTDLL".

    I had a print issue with ReportBuilder 12.03 when the Windows print
    spooler service was not enabled (Windows Server 2008).

    Enabling the print spooler service resolved the issue I was experiencing.


This discussion has been closed.