Article ID: 114775
Article Last Modified on 12/9/2003
84251 : How to Create a Topmost or Floating Window in Visual Basic
Sub Form_Load()
Form2.Show 'display the child form
Form1.Caption = "Parent"
Form2.Caption = "Child"
End Sub
' Enter the following Declare statement as one, single line:
Declare Function SetWindowWord Lib "User" (ByVal hwnd As Integer,
ByVal Index As Integer, ByVal wNewWord As Integer) As Integer
Const GWW_HWNDPARENT = (-8)
Dim OriginalParenthWnd As Integer
Sub Form_Load()
' Set parent for the toolbar to display on top of:
OriginalParenthWnd = SetWindowWord(Me.hWnd, GWW_HWNDPARENT, Form1.hWnd)
Me.Width = Form1.Width \ 3 ' Scale child form
Me.Height = Form1.Height \ 3
End Sub
Sub Form_Unload()
Dim ret As Integer
' Return the original parent handle to avoid a GP Fault
ret = SetWindowWord(Me.hWnd, GWW_HWNDPARENT, OriginalParenthWnd)
End Sub
Additional query words: 2.00 3.00
Keywords: KB114775