I've managed to solve the problem...though my problem encountered was a different but similar case..
My problem was to have only one "application taskbar window" with the focus despite having a focused seondary form displayed outside the main window in the desktop.
To tackle the problem, the Main Window must be set as a child(NOT MDI CHILD) to a Invisible Window.
Afterwhich, all secondary forms are to be set the child as the Main Window.
To set the child to a invisible window, the Setwindowlong function declared in the user32.dll must be used with the parent arguement set as 0&. A window style of WS_POPUPWINDOW must also be set...
I've tested the solution against the 9x/Me/NT/2000 platform, and it works!
create 2 forms...Form1 & Form2
place a command button on each of the form
add a module to the project and place the code as follows..
'Place this in a module file **************************
Private Const GWL_HWNDPARENT As Long = (-8&)
Private Const WS_BORDER = &H800000
Private Const WS_POPUP = &H80000000
Private Const WS_SYSMENU = &H80000
Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd&, ByVal nIndex&, ByVal dwNewLong&) As Long
Public Sub SetOwner(ByVal bSetOrRestore As Boolean, ByVal hParent&, ByVal hMe&)
If bSetOrRestore Then
SetWindowLong hMe, GWL_HWNDPARENT Or -16, hParent Or WS_POPUPWINDOW
'WS_TILEDWINDOW is the same as WS_OVERLAPPEDWINDOW
'WS_POPUP has the same effect as the 2 styles
ElseIf bSetOrRestore = False Then
SetWindowLong hMe, GWL_HWNDPARENT, 0&
End If
End Sub
'end of Declaration of the module******************
'Declaration for form1 ****************************
Private Sub Command1_Click()
Form2.Show 1, Me
End Sub
Private Sub Form_Load()
SetOwner True, 0&, Me.hwnd
End Sub
'End of Declaration for form1 ****************************
'Declaration for form2 ***********************************
Private Sub Command1_Click()
MsgBox "Form2 does not hide behind Form1 anymore"
End Sub
Private Sub Form_Load()
SetOwner True, Form1.hwnd, Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetOwner False, Form1.hwnd, Me.hwnd
End Sub
'End of declaration **************************************
David Yang