<dllimport("user32.dll")> _
Friend Shared Function SetParent(ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
End Function
'To make the form a child, we need to use the SetWindowLong API function. But, of course, to use it, we need to declare it first. While we're at it, we will also declare a few constants.
'The constant GWL_STYLE is used to tell SetWindowLong that we will be changing the window style. We use the Or operator between the constants WS_CHILD and WS_VISIBLE, so that both these "styles" are set for the form's window:
Friend Const GWL_STYLE = (-16)
Friend Const WS_CHILD = &H40000000
Friend Const WS_VISIBLE = &H10000000
<dllimport("user32.dll")> _
Friend Shared Function SetWindowLong(ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewinteger As Integer) As Integer
End Function
'1st create an instance of a form to be the child , eg called frmMain
Dim formHandle As Integer
' Create a new window to be the parent - (this could be any form or window, not just a visio window)
wAddon = myparentapp.App.ActiveWindow.Windows.Add("Parent Window", VisWindowStates.visWSDockedLeft Or VisWindowStates.visWSVisible, VisWinTypes.visAnchorBarAddon, , , 300, 210)
'Get a handle to the form
formHandle = frmMain.Handle.ToInt32
' set the form's Child attrib so it can be a child
retVal = SetWindowLong(formHandle2, GWL_STYLE, WS_CHILD Or WS_VISIBLE)
'Now that we have set the form as a child and got the form handle, make the SetParent API call
retVal2 = SetParent(formHandle2, wAddon.WindowHandle32)