Link to home
Start Free TrialLog in
Avatar of escheider
escheider

asked on

MDI Forms and DLL

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

thanks

escheider
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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.
Avatar of twalgrave
twalgrave

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.
Avatar of escheider

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of twalgrave
twalgrave

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

escheider