I have hit a snag trying to use the SetParent function of the Win32 API to place a normal form inside of an MDI child form.
So my normal form will be a sort of MDI grandchild (don't ask)
Anyway, first I did this:
This kinda worked. Everything looks good and works good except if I call GetParent() on the child it returns 0 as if it is a top level window instead of a grandchild!
So, I changed the window style of the grandchild window. Now the function looks like this:
Well, that fixed the GetParent() problem, now I can get the handle to the parent window just fine. But now the grandchild window is partially disabled. Mostly disabled even. The title bar is always the inactive color but I can use it to drag it around and clicking the [x] closes it. The buttons on the grandchild won't click but the a click event on the form itself will fire just fine.
So I studied the
MSDN for SetParent() and decided to add this:
SendMessage Me.hwnd, WM_UPDATEUISTATE, &H40001, 0
But that didn't do anything.
Does anyone have a tip or a hint that might help me?
So my normal form will be a sort of MDI grandchild (don't ask)
Anyway, first I did this:
Code:
Private Sub SetChild(oForm As VB.Form)
mlOldParent = SetParent(oForm.hwnd, Me.hwnd)
End Sub
This kinda worked. Everything looks good and works good except if I call GetParent() on the child it returns 0 as if it is a top level window instead of a grandchild!
So, I changed the window style of the grandchild window. Now the function looks like this:
Code:
Private Sub SetChild(oForm As VB.Form)
'Apply the "child" style to the form
Dim lStyle As Long
lStyle = GetWindowLong(oForm.hwnd, GWL_STYLE)
lStyle = lStyle Or WS_CHILD
SetWindowLong oForm.hwnd, GWL_STYLE, lStyle
'Swap parent here:
mlOldParent = SetParent(oForm.hwnd, Me.hwnd)
End Sub
Well, that fixed the GetParent() problem, now I can get the handle to the parent window just fine. But now the grandchild window is partially disabled. Mostly disabled even. The title bar is always the inactive color but I can use it to drag it around and clicking the [x] closes it. The buttons on the grandchild won't click but the a click event on the form itself will fire just fine.
So I studied the
MSDN for SetParent() and decided to add this:
SendMessage Me.hwnd, WM_UPDATEUISTATE, &H40001, 0
But that didn't do anything.
Does anyone have a tip or a hint that might help me?