Results 1 to 3 of 3

Thread: MDI-Child Forms

  1. #1
    Guest

    Question

    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

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    Perth Western Australia
    Posts
    41

    Cool

    Basically the theory sounds fine........ but It cannot be done! I have tried many times before and it is frought with problems. I refer you to a magazine article in Visual Basic Programmers Journal Issue March 1999 Vol 9 No 3. It has a very lengthy article on this issue with a sound solution. (To detailed to print here) Try their WEB at http://www.vbpj.com The Locator ID for the articles code is VBPJ0399 unfortunately this is only the code and not the article text. I think if you are a Premier Member then you can access old magazine articles (I am not!).

    Hope this NONE answer at least helps in some way.

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Location
    Fort Lauderdale, FL USA
    Posts
    112
    I know this is an older post, but I too had the same desire to create an MDI application with dynamic activex dll child forms. Microsoft has included a copy of the article in MSDN that CGTS talks about.

    http://msdn.microsoft.com/library/pe...d99/da0399.htm

    Damonous

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width