Visiblewindows Is Behind My Windows Form Follow


I have a simple Windows Form program that I wrote in Visual Basic in Visual Studio 2010. I reference the COM Bartend.exe. I then add a form to the project with a simple button on it.

When I click the button the code below fires.


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim btApp As New BarTender.Application
            Dim btFormat As New BarTender.Format

            btFormat = btApp.Formats.Open("C:\Temp\oper-to-stock-addr.btw", False, "")

            Dim strNamedSubstringValues = btFormat.NamedSubStrings.GetAll(":", ";")
            btFormat.Printer = "PDF-XChange 4.0"

            btApp.TopMost = True
            btApp.VisibleWindows = 2

            btFormat.PrintOut(False, False)

            btFormat.Close(1) '(bartender.BtSaveOptions.btDoNotSaveChanges)
            btApp.Quit(1) '(btDoNotSaveChanges)
            btApp = Nothing
        Catch ex As Exception
        End Try
    End Sub


My problem is the Dialog box that pops up from the Bartender label is behind my Windows form. Any idea on how to get the Dialog box in front of the windows form??


Legacy Poster
Comment actions Permalink

Found my problem. I had the form1.TopMost = true. Therefore it was trumping the btapp.TopMost.

Before printing I set the form1.topmost = false and then set it back to true at the end.

Please sign in to leave a comment.