Can't Do A Print Preview From Print Dialog? 追蹤

0
Avatar
Legacy Poster

I am using a Trial version of Automation edition, version 10.1.

 

I am automating a label from Delphi 7 using the Active X interface, and it is working quite well with one odd exception.

 

If I call

 

    myFormat.PrintOut(True, True);

 

I get the normal print dialog.  The 'Print Preview' button on the dialog is enabled.

 

However, if I click the button, the print dialog just disappears and I am returned to the next statement in my program.  Also, I have noticed that when I do this, and quit the program, even though the program is doing a .Quit on the application object, BarTender.exe keeps running in the background, which otherwise does not happen.

 

Programmatically doing a PrintPreview as:

 

      myFormat.PrintPreview.ShowDialog;
 
works fine.
 
I would like to either know how to get the print preview to work from the normal print dialog, or to disable the button.
 
Thanks.

5 意見

0
Avatar
Ian Cummings
版主
評論操作 永久連結

You'd probably want to make use of the Application.VisibleWindows Property until you get the result you want.

 
Description 
Sets which components of the BarTender application will be visible when it runs.
 
Syntax 
Application.VisibleWindows = BarTender.BtVisibleWindows.visibleWindowState 
 
Where visibleWindowState can be set to one of the following:
 
• btNone. No BarTender visibility; this is the default setting for the VisibleWindows property.
 
• btAll. Full BarTender visibility, including main windows and all interactive dialogs.
 
• btInteractiveDialogs. BarTender visibility constrained to interactive dialogs and messages. The BarTender main user interface will not be visible.
 
• btStartingLabelDialogOnly. BarTender visibility constrained to only the Starting Label dialog.
0
Avatar
Legacy Poster
評論操作 永久連結

I already had btInteractiveDialogs set, when having the problem as described.

 

btAll seems unsuitable, because it brings up the designer window for the format.

 

btStartingLabelDialogOnly does not allow preview at all, but at least the Preview button is disabled.

 

With btInteractiveDialogs set, it is almost as if the preview cannot display, and later it causes bartender.exe to not terminate on program exit - as if it is hung trying to do something.

0
Avatar
Ian Cummings
版主
評論操作 永久連結

Therefore doing a print preview within BarTender is not the way to go.  It just doesn't work the way you want.  Sorry.

 

It should be noted that the Enterprise Automation edition supports a ExportPrintPreviewToImage method for producing a print preview within your application.  This should be your ideal route to producing a print preview to give the user experience you want.  Here is an example of its use in C#:

// Declare a BarTender application variable  
BarTender.Application btApp; 

// Declare a BarTender document variable  
BarTender.Format btFormat; 

// Declare a BarTender messages variable  
BarTender.Messages msgs; 

// Create a new instance of BarTender  
btApp = new BarTender.Application();

// Set the BarTender application visible 
btApp.Visible = true;

// Open a BarTender document 
btFormat = btApp.Formats.Open("c:\\Format1.btw", false, "");

// Export document to a print preview 
BarTender.BtPrintResult res; 

res = btFormat.ExportPrintPreviewToImage("c:\\", "Label_%PageNumber%_Preview.jpg", "jpg", BarTender.BtColors.btColors24Bit, 200, 13117215, BarTender.BtSaveOptions.btSaveChanges, true, true, out msgs);

// End the BarTender process  
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges); 

0
Avatar
Legacy Poster
評論操作 永久連結

I can provide Print Preview just fine, as a separate option in my program, by doing PrintPreview.ShowDialog, as explained in my first post; no need to do ExportPrintPreviewToImage.

 

What I was concerned about was that PrintOut() was allowing the user to click a PrintPreview button within the print dialog, but nothing was happening, and it caused the bartender.exe instance to hang around at program termination.

 

I can set btStartingLabelDialogOnly to keep the user from doing that, so I am good for now.

 

I think that allowing a print preview button click with no resulting print preview and not being able to subsequently terminate BarTender.exe with a .Quit is a bug of some sort.

 

I will probably test later from C# and see if I have the same issue.  Is there such a thing as bug reporting for BarTender?

 

Thanks for your prompt attention and help.

0
Avatar
Ian Cummings
版主
評論操作 永久連結

This sort of problem is known, but unfortunately there is not much we can do about it save showing the whole BarTender application.  It's just not the recommended way of doing things.

登入寫評論。