?? How do I close another application that has a modal dialog open ??


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: ?? How do I close another application that has a modal dialog open ??

  1. #1
    MilOs Guest

    ?? How do I close another application that has a modal dialog open ??

    I have an application that will shut down all instances of another specific
    application ( ie. like Word). But it has problems if the application has a
    modal dialog window open.

    I have tried getting the handle to the dialog box and setting it to the
    active window and then using sendkeys() to close the dialog window. I am
    not to happy with this method.

    Is there an API call that I can make to close the the window or even send it
    a message like ID_CANCEL or ID_OK ???


    Thanx


    Milos




  2. #2
    Necator Guest

    Re: ?? How do I close another application that has a modal dialog open ??


    Try to use the PostMesage method.


    'Get DAP hwnd
    DAPhWnd = FindWindow("DAP Class", "Download Accelerator Plus - DAP")
    If DAPhWnd Then
    PostMessage DAPhWnd, WM_CLOSE, 0, 0
    End If


  3. #3
    Necator Guest

    Re: ?? How do I close another application that has a modal dialog open ??


    Try to use the PostMesage method.


    'Get DAP hwnd
    DAPhWnd = FindWindow("DAP Class", "Download Accelerator Plus - DAP")
    If DAPhWnd Then
    PostMessage DAPhWnd, WM_CLOSE, 0, 0
    End If


  4. #4
    MiLoS Guest

    Re: ?? How do I close another application that has a modal dialog open ??


    Thanx But,
    That is the method that I am using to close the application but the
    application will not close if it has a modal dialog window open, like an
    error message.

    Necator <necator@ladnet.cjb.net> wrote in message
    news:3a6990bb$1@news.devx.com...
    >
    > Try to use the PostMesage method.
    >
    >
    > 'Get DAP hwnd
    > DAPhWnd = FindWindow("DAP Class", "Download Accelerator Plus - DAP")
    > If DAPhWnd Then
    > PostMessage DAPhWnd, WM_CLOSE, 0, 0
    > End If
    >




  5. #5
    MiLoS Guest

    Re: ?? How do I close another application that has a modal dialog open ??


    Thanx But,
    That is the method that I am using to close the application but the
    application will not close if it has a modal dialog window open, like an
    error message.

    Necator <necator@ladnet.cjb.net> wrote in message
    news:3a6990bb$1@news.devx.com...
    >
    > Try to use the PostMesage method.
    >
    >
    > 'Get DAP hwnd
    > DAPhWnd = FindWindow("DAP Class", "Download Accelerator Plus - DAP")
    > If DAPhWnd Then
    > PostMessage DAPhWnd, WM_CLOSE, 0, 0
    > End If
    >




  6. #6
    Dick Grier Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    Hi,

    There is example code on www.msdn.microsoft.com. It uses the
    TerminateProcess API (search on TerminateProcess to find the specific code)

    Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, _
    ByVal uExitCode As Long) As Long

    --
    Richard Grier (Microsoft Visual Basic MVP)
    Hard & Software
    12962 West Louisiana Avenue
    Lakewood, CO 80228
    303-986-2179 (voice)
    303-986-3143 (fax)
    Author of Visual Basic Programmer's Guide to Serial Communications, 2nd
    Edition ISBN 1-890422-25-8 (355 pages).
    For information look on my homepage at http://www.hardandsoftware.net.
    Use the Books link to order. For faster service contact the publisher at
    http://www.mabry.com/vbpgser.





  7. #7
    Dick Grier Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    Hi,

    There is example code on www.msdn.microsoft.com. It uses the
    TerminateProcess API (search on TerminateProcess to find the specific code)

    Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, _
    ByVal uExitCode As Long) As Long

    --
    Richard Grier (Microsoft Visual Basic MVP)
    Hard & Software
    12962 West Louisiana Avenue
    Lakewood, CO 80228
    303-986-2179 (voice)
    303-986-3143 (fax)
    Author of Visual Basic Programmer's Guide to Serial Communications, 2nd
    Edition ISBN 1-890422-25-8 (355 pages).
    For information look on my homepage at http://www.hardandsoftware.net.
    Use the Books link to order. For faster service contact the publisher at
    http://www.mabry.com/vbpgser.





  8. #8
    Sergey Merzlikin Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    Hello!

    You must close this modal window first.

    Here is an example: http://smsoft.chat.ru/en/shutdown.htm

    --
    Sergey Merzlikin
    http://smsoft.chat.ru
    smsoft@chat.ru


    "MilOs" <milosk@hella.net> wrote in message news:3a68b075$1@news.devx.com...
    > I have an application that will shut down all instances of another

    specific
    > application ( ie. like Word). But it has problems if the application has

    a
    > modal dialog window open.
    >
    > I have tried getting the handle to the dialog box and setting it to the
    > active window and then using sendkeys() to close the dialog window. I am
    > not to happy with this method.
    >
    > Is there an API call that I can make to close the the window or even send

    it
    > a message like ID_CANCEL or ID_OK ???
    >
    >
    > Thanx
    >
    >
    > Milos
    >
    >
    >




  9. #9
    Sergey Merzlikin Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    Hello!

    You must close this modal window first.

    Here is an example: http://smsoft.chat.ru/en/shutdown.htm

    --
    Sergey Merzlikin
    http://smsoft.chat.ru
    smsoft@chat.ru


    "MilOs" <milosk@hella.net> wrote in message news:3a68b075$1@news.devx.com...
    > I have an application that will shut down all instances of another

    specific
    > application ( ie. like Word). But it has problems if the application has

    a
    > modal dialog window open.
    >
    > I have tried getting the handle to the dialog box and setting it to the
    > active window and then using sendkeys() to close the dialog window. I am
    > not to happy with this method.
    >
    > Is there an API call that I can make to close the the window or even send

    it
    > a message like ID_CANCEL or ID_OK ???
    >
    >
    > Thanx
    >
    >
    > Milos
    >
    >
    >




  10. #10
    Dean Earley Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    This is just an idea, but could you send the query unload message. Im not
    sure of the specifics

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems
    "MilOs" <milosk@hella.net> wrote in message news:3a68b075$1@news.devx.com...
    > I have an application that will shut down all instances of another

    specific
    > application ( ie. like Word). But it has problems if the application has

    a
    > modal dialog window open.
    >
    > I have tried getting the handle to the dialog box and setting it to the
    > active window and then using sendkeys() to close the dialog window. I am
    > not to happy with this method.
    >
    > Is there an API call that I can make to close the the window or even send

    it
    > a message like ID_CANCEL or ID_OK ???
    >
    >
    > Thanx
    >
    >
    > Milos
    >
    >
    >




  11. #11
    Dean Earley Guest

    Re: ?? How do I close another application that has a modal dialog open ??

    This is just an idea, but could you send the query unload message. Im not
    sure of the specifics

    --
    Dean Earley (dean.earley@icode.co.uk)
    Assistant Developer

    iCode Systems
    "MilOs" <milosk@hella.net> wrote in message news:3a68b075$1@news.devx.com...
    > I have an application that will shut down all instances of another

    specific
    > application ( ie. like Word). But it has problems if the application has

    a
    > modal dialog window open.
    >
    > I have tried getting the handle to the dialog box and setting it to the
    > active window and then using sendkeys() to close the dialog window. I am
    > not to happy with this method.
    >
    > Is there an API call that I can make to close the the window or even send

    it
    > a message like ID_CANCEL or ID_OK ???
    >
    >
    > Thanx
    >
    >
    > Milos
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center