Keeping A Form On Top Of A Window

Instead of SetWindowPos, it uses SetWindowWord. This lets you create a floating toolbar that stays above its app’s window without staying on top of ALL windows. Very handy for that professional look.

Declare Sub SetWindowWord Lib "USER" (ByVal hWnd, ByVal nCmd, ByVal nVal) 
Const SWW_hParent = (-8)

Form_Load of the form that you want to keep on top. Set it about form1.

Sub Form_Load () 
     SetWindowWord hWnd, SWW_hParent, form1.hWnd
End Sub

Form_Unload of the from you want to keep on top this is for cleaning up.

Sub Form_Unload (Cancel As Integer) 
     SetWindowWord hWnd, SWW_hParent, 0
End Sub

 

Tip Submitted By: Jonathon Twigg