minimize another application that my application starts

Posted on 2004-11-17
Last Modified: 2007-11-27
The application I have starts another application.  I want that one to be minimized.

Question by:sherrick123
    LVL 7

    Expert Comment

    If your called application is a windows form, use

    dim frm as New MyForm
    frm.WindowState = FormWindowState.Minimized
    LVL 7

    Expert Comment

    If it is a console (non-windows form) app, I start my stuff as a Process so I can monitor when it finishes:

    Dim pi As ProcessStartInfo = New ProcessStartInfo(sAppPtath, sAppCommandLineParms)
    pi.Verb = "open"
    pi.WindowStyle = ProcessWindowStyle.Minimized
    pi.CreateNoWindow() = True
    pi.UseShellExecute = True
    Dim p As Process = System.Diagnostics.Process.Start(pi)
    Dim i As Integer = 0
    For i = 0 To 60 'Give the process 15 seconds to finish
      If p.HasExited Then
        Exit For
      End If
      'Let the system catch up

    If i => 60 Then 'Processdidn't complete in time allowed
      msgbox("Error...",vbOkOnly, "Process didn't finish in time")
    End If

    If you don't need to monitor for completion, don't use the FOR loop

    Hope these help,

    Author Comment

    Here is my routine.  I marked the application that I am starting.

    Dim oScanEnumerator As MicroStationDGN.ElementEnumerator
            Dim oScanCriteria As MicroStationDGN.ElementScanCriteria
            Dim oMyMicroStation As New MicroStationDGN.Application   'This is the application I start
            Dim oDesign As MicroStationDGN.DesignFile
            Dim oElement As MicroStationDGN.Element
            Dim oElementRange As MicroStationDGN.Range3d
            Dim omyView As MicroStationDGN.View
            Dim oIsThereAFence As Boolean
            Dim oPDFName As String
            Dim oPrintPath As String
            Dim i As Integer
            Dim oPrintCommand As String

            oIsThereAFence = False

            oScanCriteria = New MicroStationDGN.ElementScanCriteria

            i = InStr(DgnFile.ToString, ".dgn")
            oPDFName = Mid(DgnFile.ToString, 1, i - 1) & ".pdf"
            oPrintPath = cboFiles.SelectedItem.ToString & "\Images\" & oPDFName

            oMyMicroStation.Visible = True

    'This is where I am opening the application
            oDesign = oMyMicroStation.OpenDesignFile(DgnFile.FullName.ToString, False, MicroStationDGN.MsdV7Action.msdV7ActionWorkmode)
    LVL 7

    Expert Comment

    It looks like that's going to be a function of the MicroStationDGN object.  I've never worked with it (actually, I had to look up what MicroStation DGN was).  Is there nothing in the documentation?  I couldn't find anything on the web that was useful.  My bluff would be that you might be able to use the .Visible property to do what you need.  But, if not, there might be a .Handle property that you can use to find the window and then you can Minimize the app from there. I've not tried to do that in VB.NET, so I'm sorry, but I can't help you there.

    What are you trying to open, btw?  I see you're trying to work with a PDF file, but I don't see what the outcome is.  Are you just trying to print the PDF file using MicroStation?  If so, I've found a great object that prints PDFs silently.  Let me know, I'll post the link to that.


    Author Comment


    I am creating a PDF from a MicroStation Design file (CAD File).  The problem I found out when you minimize it and take the focus away from the application the plot process does not work.
    LVL 7

    Expert Comment

    That, unfortunately, sounds like it is a function of the MicroStation component/application.  Not sure why is would monitor focus while it is processing, but evidently it does.

    I'm not a CAD expert (or CAD-anything, for that matter, I can spell it, that's about it).  Do you have the ability to produce a SVG (scalable vector graphics) or any other image of your CAD document?  I use this componet,, in an unattended program to embed JPG files of signatures into PDF documents.  It converts XSL:FO doucments into PDF documents.  It's very quick and efficient and relatively easy to implement into a .NET program.  Wrapping a SVG version of your CAD file in an XSL:FO document is not a difficult thing to do.  It might be worth a look, if the non-focus execution is a must.

    Sorry I couldn't help more,

    Author Comment


    I have it working now.  Talked to the vendor and it is Working as Designed
    LVL 7

    Accepted Solution

    Great.  Glad you solved your problem.  You should post the solution, in case someone else has the same issues.

    Also, you'll want to request a refund because you answered your own question (Refund/PAQ)

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now