Article ID: 126386
Article Last Modified on 10/30/2003
'Enter each Declare statement as one, single line:
Declare Function GetActiveWindow Lib "User" () As Integer
Declare Function GetWindow Lib "User"
(ByVal hWnd As Integer, ByVal wCmd As Integer) As Integer
Declare Function SetActiveWindow Lib "User"
(ByVal hWnd As Integer) As Integer
Global Const GW_HWNDFIRST = 0
Global Const GW_HWNDNEXT = 2
Sub Command1_Click ()
Dim TopMosthWnd%, OldActivehWnd%, NewActivehWnd%
TopMosthWnd% = GetWindow(Me.hWnd, GW_HWNDFIRST)
OldActivehWnd% = SetActiveWindow(TopMosthWnd%)
NewActivehWnd% = GetActiveWindow()
' The following code is required only if there is more than one
' non-child form in the project. In this case you will have to
' start from the next topmost window, if focus shifts to the
' other non-child forms, just before this code on the original
' form is executed.
While NewActivehWnd% = 0
TopMosthWnd% = GetWindow(TopMosthWnd%, GW_HWNDNEXT)
OldActivehWnd% = SetActiveWindow(TopMosthWnd%)
NewActivehWnd% = GetActiveWindow()
Wend
End Sub
' This is Optional. It is used to show the effect of another
' non-child form:
Sub Form_Load ()
form2.Show
End Sub
TopMosthWnd% = GetWindow(Me.hWnd, GW_HWNDFIRST)
TopMosthWnd% = GetWindow(Me.hWnd, GW_OWNER) TopMosthWnd% = GetWindow(TopMosthWnd%, GW_HWNDFIRST)
Global Const GW_OWNER = 4
Additional query words: 3.00
Keywords: KB126386