Skip to main content

Search

Search

Printer Selection Dialog Window (.net Sdk)

Comments

11 comments

  • Avatar
    Ian Cummings
    Moderator

    You need to make use of the Window class.  However, it looks like setting the VisibleWindows to InteractiveDialogs won't allow you to show this Print dialog.  This only works for data entry and database query dialogs.  Instead you'd need to show the whole BarTender application window which is not what you want.  Is there any reason why you don't use a form control in your app, populate it with the installed printers, and then set the printer selected as the one to use in the BarTender print job?  The LabelPrint project in the SDK gives a good example on how to do this.

     

    Anyhow, here is some code I inserted into a button click event for demo purposes:

                // Create and Start the BarTender print engine.
                Engine btEngine = new Engine();
                btEngine.Start();
    
                // Set the BarTender main window dimensions.
                btEngine.Window.Width = 800;
                btEngine.Window.Height = 600;
    
                // Set the window location.
                btEngine.Window.Top = 100;
                btEngine.Window.Left = 100;
    
                // Make BarTender visible to the user.
                btEngine.Window.VisibleWindows = VisibleWindows.InteractiveDialogs;
                //btEngine.Window.Visible = true;
    
    
                // Open a label format. 
                LabelFormatDocument btFormat = btEngine.Documents.Open(@"C:\users\icummings\desktop\document1.btw");
    
                // Print the label 
                Result result = btFormat.Print(); 
                
                // Wait five seconds so the user can see the window.
                System.Threading.Thread.Sleep(5000);
    
                // Stop the BarTender print engine.
                btEngine.Stop();
    
    0
  • Avatar
    Ben Roland

    This is what I was looking for! a way to display select record.... do you know if there is a way to hide bartender yet still display the select record dialog box? I'm also considering using a datagridview in my program to accomplish the same thing? 

    0
  • Avatar
    Ian Cummings
    Moderator

    Set the VisibleWindows property with one of the below enumerations:

    VisibleWindows Enumeration

      Member name Value Description
      None 0 No windows will be visible in BarTender.
      All 1 All windows will be visible in BarTender.
      InteractiveDialogs 2 Only interactive dialog windows will be visible in BarTender. The main BarTender window will not show.
      StartingLabelDialogOnly 3 Only the starting label dialog will be visible in BarTender.

     

    0
  • Avatar
    Ben Roland

    Ian, from my testing:

    from my testing:

    btEngine.Window.VisibleWindows = VisibleWindows.InteractiveDialogs
    btEngine.Window.Visible = True

    or

    btEngine.Window.VisibleWindows = VisibleWindows.All
    btEngine.Window.Visible = True

    or 

    btEngine.Window.VisibleWindows = VisibleWindows.None
    btEngine.Window.Visible = True

    or

    btEngine.Window.VisibleWindows = VisibleWindows.StartingLabelDialogOnly
    btEngine.Window.Visible = True

    All behave the same... there is no diffrance. They alll show the BarTender program. 

    Do you have any examples of code that hide the BarTender Program but will show the Interactive Dialogs?

    Here is what my Sub in VB looks like and is working other then I would like to hide BarTender.

    Private Sub LabelPrint()
    Dim btEngine As New Engine()


    ' Start a BarTender Engine process

    btEngine.Start()
    ' Set the BarTender main window dimensions.
    btEngine.Window.Width = 800
    btEngine.Window.Height = 600

    'Set the window location.
    btEngine.Window.Top = 20
    btEngine.Window.Left = 20

    ' Make BarTender visible to the user.
    btEngine.Window.VisibleWindows = VisibleWindows.InteractiveDialogs
    btEngine.Window.Visible = True

    ' Open a label format

    Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("\\PCS-FS01\Software\PCS Shipping\V2\Labels\QR Codes Linked to Database.btw")

    ' Set the QueryPrompt

    btFormat.DatabaseConnections.QueryPrompts("Job_Number").Value = lbJob.Text
    btFormat.DatabaseConnections.QueryPrompts("System_Number").Value = lbSys.Text

    ' Print the label format

    Dim result As Result = btFormat.Print()

    ' Wait five seconds so the user can see the window.
    System.Threading.Thread.Sleep(5000)

    ' Stop the BarTender print engine.
    btEngine.Stop()

    End Sub

    0
  • Avatar
    Ian Cummings
    Moderator

    What version/build of BarTender are you running?  What version of Windows?

    0
  • Avatar
    Ben Roland

    Win 10 Pro, Visual Studio 17, BarTender Enterprise Automation 2016 R3

    0
  • Avatar
    Kai Kohler

    Hi Ben,

    You may need to add a Record Picker Control to the form on the .btw document.  Instructions can be found here: https://support.seagullscientific.com/hc/en-us/articles/214448107

    Then you need to make a minor change in your code - you are setting the VisibleWindows property to the member name rather than the value:

    ' Make BarTender visible to the user.
    btEngine.Window.VisibleWindows = 2
    btEngine.Window.Visible = True
    0
  • Avatar
    Ben Roland

    Kai,

    That change had the same outcome. looks like my only option is

    btEngine.Start()
    ' Set the BarTender main window dimensions.
    btEngine.Window.Width = 0
    btEngine.Window.Height = 0

    'Set the window location.
    btEngine.Window.Top = 1600
    btEngine.Window.Left = 1600

    Giving it the width and height of 0 does not hide it, it still shows a small title bar. I made the location off my screen so it will not show up.

    0
  • Avatar
    Ben Roland

    Also, I am using the record picker. that is the dialog box I want to show while hiding the BarTender program.

    0
  • Avatar
    Kai Kohler

    Ben,

    Interestingly enough ... it looks like it's an order of operations issue.  Make this change:

    ' Make BarTender visible to the user.
    btEngine.Window.Visible = True
    btEngine.Window.VisibleWindows = 2

    I should have double checked before my last post, but apparently the order of those two lines matters.  If Window.Visible is after Window.VisibleWindows it will still open the main BarTender window.

    0
  • Avatar
    Ben Roland

    Kai,

    Sweet! that did the trick.

    Thanks!

    0

Please sign in to leave a comment.