Results 1 to 3 of 3

Thread: setting top window current

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Location
    canada
    Posts
    22

    setting top window current

    Seriously, I have spent over 12 hours on this one problem. I'm begging you to help me.

    What is the code required to utilize API functions to set the top window current?

    I use the AppActivate function to set another application current. The application that is being sent current is an application that I did NOT develop. When the focus is switched to this application, the parent window is active. I want to set current whatever child window is the topmost window.

    I am using VB5 and this must work on both NT4 and 2000.


    Thanks very much to anyone that can help me.

    Ryan

  2. #2
    Junior Member
    Join Date
    Mar 2001
    Posts
    18

    I think this is what you are looking for.

    Option Explicit
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, Y, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_SHOWWINDOW = &H40
    Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE

    '// Resets the windows position in the ZOrder
    Public Sub MakeNormal(lngHwnd As Long)
    SetWindowPos lngHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    End Sub

    '// Places the window at the top of the ZOrder
    '// and keeps it there
    Public Sub MakeTopMost(lngHwnd As Long)
    SetWindowPos lngHwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS
    End Sub

  3. #3
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Caution: I personally wouldn't use:
    SetWindowPos lngHwnd, HWND_NOTOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS

    As your app's will dominate over all others unless it is minimised, which will really annoy users

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