Keep window on top (of all forms)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Keep window on top (of all forms)

  1. #1
    kanders Guest

    Keep window on top (of all forms)


    My VB6 program needs to keep a window activated by another program on top
    of all currently visible windows. For background, my operating system is
    WinNT Workstation 4.0 (Service Pack 6) and all programs are 32-bit implementations.

    The problem arises when the user selects print-to-file. The program external
    to my own activates a function in an always- running auxilliary .EXE that
    accepts the user's inputted directory location. This text input box often
    pops up behind both my main form and the calling program's main form.

    I know the name and location of the input box executable, but that's about
    all. What's the best way to keep its window on top (and in focus)?

    Thanks in advance.

  2. #2
    Eric D. Burdo Guest

    Re: Keep window on top (of all forms)

    Get the window handle of the window that pops up, and give it OnTop status.

    --

    Eric D. Burdo, Red-Leif International
    VB Programmer and Consultant
    <http://www.redleif.com/vb>

    *** Please reply to the newsgroup so all can benefit. ***


    "kanders" <kanders@pacbell.net> wrote in message news:3a01fd78$1@news.devx.com...
    >
    > My VB6 program needs to keep a window activated by another program on top
    > of all currently visible windows. For background, my operating system is
    > WinNT Workstation 4.0 (Service Pack 6) and all programs are 32-bit implementations.
    >
    > The problem arises when the user selects print-to-file. The program external
    > to my own activates a function in an always- running auxilliary .EXE that
    > accepts the user's inputted directory location. This text input box often
    > pops up behind both my main form and the calling program's main form.
    >
    > I know the name and location of the input box executable, but that's about
    > all. What's the best way to keep its window on top (and in focus)?
    >
    > Thanks in advance.




  3. #3
    Eric D. Burdo Guest

    Re: Keep window on top (of all forms)

    Get the window handle of the window that pops up, and give it OnTop status.

    --

    Eric D. Burdo, Red-Leif International
    VB Programmer and Consultant
    <http://www.redleif.com/vb>

    *** Please reply to the newsgroup so all can benefit. ***


    "kanders" <kanders@pacbell.net> wrote in message news:3a01fd78$1@news.devx.com...
    >
    > My VB6 program needs to keep a window activated by another program on top
    > of all currently visible windows. For background, my operating system is
    > WinNT Workstation 4.0 (Service Pack 6) and all programs are 32-bit implementations.
    >
    > The problem arises when the user selects print-to-file. The program external
    > to my own activates a function in an always- running auxilliary .EXE that
    > accepts the user's inputted directory location. This text input box often
    > pops up behind both my main form and the calling program's main form.
    >
    > I know the name and location of the input box executable, but that's about
    > all. What's the best way to keep its window on top (and in focus)?
    >
    > Thanks in advance.




  4. #4
    Travis Hall Guest

    Re: Keep window on top (of all forms)


    "Eric D. Burdo" <vbtips@redleif.com> wrote:
    >Get the window handle of the window that pops up, and give it OnTop status.


    While Eric's answer is entirely accurate, it probably doesn't give enough
    information to actually implement a solution. Use FindWindow to retrieve
    the handle to the appropriate window (remembering to check that you don't
    get back a null handle, which indicates that the window sought wasn't found).
    Then, use SetWindowPos to put the window on top, specifying HWND_TOPMOST
    if you want to make sure this window is always on top of all other normal
    windows or just HWND_TOP to put it on top initially if you want to let the
    user switch to a different window after this one is displayed.

    The relevant functions have declarations listed in the API Viewer.

    Travis Hall


  5. #5
    Travis Hall Guest

    Re: Keep window on top (of all forms)


    "Eric D. Burdo" <vbtips@redleif.com> wrote:
    >Get the window handle of the window that pops up, and give it OnTop status.


    While Eric's answer is entirely accurate, it probably doesn't give enough
    information to actually implement a solution. Use FindWindow to retrieve
    the handle to the appropriate window (remembering to check that you don't
    get back a null handle, which indicates that the window sought wasn't found).
    Then, use SetWindowPos to put the window on top, specifying HWND_TOPMOST
    if you want to make sure this window is always on top of all other normal
    windows or just HWND_TOP to put it on top initially if you want to let the
    user switch to a different window after this one is displayed.

    The relevant functions have declarations listed in the API Viewer.

    Travis Hall


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