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
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