MDI Forms and DLL

escheider used Ask the Experts™
Hello experts:

I've got an interesting question concerning mdi forms.

I am using two activex dlls to perform some functionality in my application.  Each dll contains a set of forms and class modules that perform various routines.  For instance, one dll performs all the invoicing routines (statements, invoices, reports, etc.), the other dll performs their other functions which I won't try to explain.

So, what I'd like to do is create a seperate application that contains an MDI form.  This MDI form would contain menus listing the various reports and forms that user could interact with.  When the menu item is selected to open a form, a call to the appropriate dll is made, and that form is opened.

My question is, is it possible to have the form or reports opened and use the MDI form as its container?

Im using vb6


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

You would need to build ActiveX control (your control should contain a complete form) and host them into an empty form currently existing in your project.
If you have the form object in memory and the MDI Form object in memory, you can try to perform a SetParent API call on it:

Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
To expand on the last response, add a property let to the dll and name it ParenthWnd.  This should be of type long.
Save the value in a local module variable.

In the mdi's form load event, assign the mdi's hwnd value to the dll's property, as in

dllName.ParenthWnd = me.hwnd

Then when you create a form within the dll, execute the line

SetParent NameOfFormObject.hwnd, m_ParenthWnd

Before you unload the form, execute

SetParent NameOfFormObject.hwnd, 0&

to undo it.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


ok bob  question:

I have a reference to my dll setup.  So, i define a variable to utilize my methods and properties within the dlls.  So, this is how I would make a call:

Private Sub dllroutine()

Dim oDllCall as clsBase.FunctionName

set oDllCall=new clsBase.FunctionName


end sub

so, my question is, where and how would i set up the following command:

dllName.ParenthWnd = me.hwnd

Do I need to put a property within the dll that handles this call?
Inside your dll,

Public property get hWndFrmInvoice() as long
  hWndFrmInvoice = frmInvoice.hwnd
end property

Public property get hWndFrmStatements() as long
  hWndFrmStatements = frmInvoice.hwnd
end property

etc for each of the forms you wnat to host in the MDI Form.

Then when you want to call the form and place it in the MDI container use this:
lRetVal = SetParent (hWndFrmStatements , MDIForm.hwnd )


ok .. i got that .. but .. here is a related issue.

I have a small form that collects some data .. a continue button is pressed on the bottom of the form, which loads and shows the next form.  How could I get the ParentContainer.hWnd from the first child form to pass to the next form to be viewed, since Im not making the call from the MDIForm?


Thank you everyone for your time and effort in resolving this issue.  I appreciate expounding on your example and helping me through this.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial