CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Posts
    305

    Keep application forms on top

    I want to keep the forms related to my forms on top of all other open applications. How do I do that? Thanks?

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Keep application forms on top

    Forms related to your Forms??

    Forms have a property called TopMost that can be set to true or false. Look at MSDN for more

  3. #3
    Join Date
    Dec 2002
    Posts
    305

    Re: Keep application forms on top

    Shuja:

    I had tried that. That has no effect. I have a non-.Net, third-party application running with its form taking up the whole screen. Now, I want to run my application so that its form shows up above the first application and remains there even when I shift control to the first application. Is that possible? I am using VS 2003. Thanks.

  4. #4
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Keep application forms on top

    I presume Form.TopMost is the same we had to achieve with an API call in VB6

    Code:
    Public Declare Function SetWindowPos Lib "user32" ( _
           ByVal hWnd As Long, _
           ByVal hWia As Long, _
           ByVal X As Long, ByVal Y As Long, _
           ByVal cx As Long, ByVal cy As Long, _
           ByVal wFlags As Long _
      ) As Long
    
    Public Const SWP_NoSize = 1&
    Public Const SWP_NoMove = 2&
    
    Public Const HWND_TopMost = -1&
    
    'the call:
      SetWindowPos FormX.hWnd, HWND_TopMost, 0, 0, 0, 0, SWP_NoSize + SWP_NoMove
    FormX.hWnd being the window handle of the app's Form.

    After calling the app's Form stays on top of all others.
    Only, if another app does the same call it will take over the topmost position.
    Maybe you can use a timer to set the TopMost property repeatedly every 500msec (either by API cal or by setting the Form's property)
    Maybe that smartens out the other app.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured