Problem: 1385305
Title: (Printing) Problems printing non-visible views
Received: Sep 5 1996 2:55PM
Having a problem with TPrintMenuBehavior::DoSetupMenus(). Want to print
a non-visible view (a non-screen version of stuff in a document window).
I create a special view (which is never shown) and create a print handler
(my own derived from TStdPrintHandler), initializing it with my document
and the special view. A TPrintMenuBehavior is attached to the document
to handle the menus. I have two problems - the second of which may be a
bug:
- When a print command is created for a non-visible detached view, the print command can't be posted (debug message) because the ::PostCommand of the view is called and it has no available handler to post the command. It seems that the command should be routed to the document in this case.
- TPrintMenuBehavior::DoMenuCommand will call the print handlers ::DoPrintCommand method if a print handler's view is a) not shown, b) active or c) finder printing. TPrintMenuBehavior::DoSetupMenus, however, enables the appropriate menu items only when the view is a) active or b) finder printing. Printing a non-shown view, therefore, is doable from ::DoMenuCommand, but not doable from ::DoSetupMenus, the net effect of which is, without overriding ::IsActive of the hidden view to TRUE, no menu items are enabled.
Thanks for you consideration of this issue. It would be nice if someone
would put together some sample code for printing a non-screen-based image
of a document or a recipe for doing so. The Programmer's Guide to MacApp
does not offer much help here.
Fix:
Fixed in UPrintHandler.cp/.h and UView.cp/.h and UEventHandler.cp
1. TView::PostCommand now trys posting to the document if the nexthandler is not available
1a. TEventHandler::PostCommand now trys posting to the gDispatcher if the nexthandler
is not available.
2. The test conditions for execution of a printing command have been made identical
between TPrintMenuBehavior::DoSetupMenus and DoMenuCommand.