Aug 27th, 2000, 08:09 PM
Hi!
I'm having trouble to create a child form in an MDI form from a DLL. I've created an ACTIVE-X DLL in VB (6.0, SP4) with a form in it. When I set it's properties to MDI child I can't load it in the main project. I've then tried the Setparent function from the API, wich worked... BUT... When I maximize the "child" form it's "Title bar" won't go away. I'd like the "normal" Child behaviour, but I want the child forms to be included in DLL's in my project.
So far I've tried these 2 methods:
' --------------------------------------
' Method 1
' --------------------------------------
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long)
Const WS_CHILD = &H40000000
Const GWL_STYLE = (-16)
Const GWL_HWNDPARENT = (-8)
Const SWP_NOZORDER = &H4
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Const HWND_TOP = 0&
Public Sub ShowWin(Wid As Long)
Dim OrigStyle As Long
Dim style As Long
Load frmDLLTest
OrigStyle = GetWindowLong(frmDLLTest.hwnd, GWL_STYLE) 'Get current window style
style = OrigStyle Or WS_CHILD 'Append "WS_CHILD" style to the hWnd window style
SetWindowLong frmDLLTest.hwnd, GWL_STYLE, style 'Add new style to window
SetParent frmDLLTest.hwnd, Wid 'Set form into parent window
SetWindowLong frmDLLTest.hwnd, GWL_HWNDPARENT, Wid 'have the hWnd Parent in hWnd's window struct.
SetWindowPos frmDLLTest.hwnd, HWND_TOP, 0&, 0&, 400, 400, SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_SHOWWINDOW ' Show the Window
End Sub
' --------------------------------------
' Method 2
' --------------------------------------
Load frmDLLTest
frmDLLTest.Show
SetParent frmDLLTest.hwnd, Wid 'Set form into parent window
What do I do wrong? Please help!!!
__________________
Regards,
Rob
I'm having trouble to create a child form in an MDI form from a DLL. I've created an ACTIVE-X DLL in VB (6.0, SP4) with a form in it. When I set it's properties to MDI child I can't load it in the main project. I've then tried the Setparent function from the API, wich worked... BUT... When I maximize the "child" form it's "Title bar" won't go away. I'd like the "normal" Child behaviour, but I want the child forms to be included in DLL's in my project.
So far I've tried these 2 methods:
' --------------------------------------
' Method 1
' --------------------------------------
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long)
Const WS_CHILD = &H40000000
Const GWL_STYLE = (-16)
Const GWL_HWNDPARENT = (-8)
Const SWP_NOZORDER = &H4
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Const HWND_TOP = 0&
Public Sub ShowWin(Wid As Long)
Dim OrigStyle As Long
Dim style As Long
Load frmDLLTest
OrigStyle = GetWindowLong(frmDLLTest.hwnd, GWL_STYLE) 'Get current window style
style = OrigStyle Or WS_CHILD 'Append "WS_CHILD" style to the hWnd window style
SetWindowLong frmDLLTest.hwnd, GWL_STYLE, style 'Add new style to window
SetParent frmDLLTest.hwnd, Wid 'Set form into parent window
SetWindowLong frmDLLTest.hwnd, GWL_HWNDPARENT, Wid 'have the hWnd Parent in hWnd's window struct.
SetWindowPos frmDLLTest.hwnd, HWND_TOP, 0&, 0&, 400, 400, SWP_NOZORDER Or SWP_NOACTIVATE Or SWP_SHOWWINDOW ' Show the Window
End Sub
' --------------------------------------
' Method 2
' --------------------------------------
Load frmDLLTest
frmDLLTest.Show
SetParent frmDLLTest.hwnd, Wid 'Set form into parent window
What do I do wrong? Please help!!!
__________________
Regards,
Rob