Link to home
Start Free TrialLog in
Avatar of Mason
Mason

asked on

MDI Child Forms within an ActiveX DLL

The project we are working on is designed using an "add-in" metaphor.  We have a very light-weight MDI front end for this project.  One thing we want to do is be able to store MDI Child forms in an ActiveX  DLL and then reference them doing something like this:

Dim frmForm as Form
Set frmForm = <ActiveX DLL Reference>.GetSearchDialog

However, this generates a VB Runtime Error 366: Unable to load MDI Form.  We are assuming this means that the MDIChild form does not have a way of knowing who its parent would be.  We have tried using the SetParent API call for this, but we need to get the hWnd property of the MDIChild. Accessing any property of the MDIChild causes this error to occur.

Any thoughts...?

Avatar of vbWhiz
vbWhiz

VB is probably not going to let you put one MDI parent's children inside another MDI parent, especially if the MDI parent for which the child is created hasn't been loaded yet. What charecteristics are you looking for in this child form? To be a child of VB's Parent form? You can gain this result by just changing the form's MDIChild property to false and then using the SetParent API Call.
Mason, I'm afraid vbWhiz is right.  You can't compile MDI children into an ActiveX DLL.  If what you're after is a container app that hosts add-ins, you have a couple of choices:

1) Write your forms as ActiveX Documents and host them inside a browser.

2) Write your own child form handler using the "SetParent" API call.  I have some friends doing this, so I know it can be done.

HTH.
You can Compile as ActiveX.EXEs and Use MDI forms.

My boss loves to use them..
I think it sucks.. I would rather
Load up in process<dll> forms and "center" them over the Parent App.

I guess in your case it might be ok.  My boss only uses it for
a standard container.  but it doesnt do anything<theMdi> except hold an Exit button. <now you know why it sucks for me>

He also loves to Late bind everything.. <Arrgh>  
Avatar of Mason

ASKER

Compiling MDI Child Forms (regular forms with the MDIChild property set to True), not an MDIForm which is used for the parent, into an ActiveX EXE does not work.  Getting a reference to an MDI Child form that is located within the Active EXE and then attempting to access any property/method always results in a VB-Runtime Error 366: Unable to load MDI Form.  Again this has something to do with the MDI Child form not knowing who its parent form would be.  Unfortunately to get the hWnd of the MDI Child form (to use the SetParent API call) you need to access a property.  I am currently looking into other API calls to do this.

Too bad the MDIChild property is design time only!!!

The whole point is to be able to host the MDI Child forms inside the parent MDI Form.  It is very easy to place a regular form (MDIChild property set to False) inside an ActiveX DLL or EXE and then load it.  However these will not be hosted inside the parent container window.  They are mearly displayed on top of the parent.

Another suggestion was to use the SetParent API call.  You can do this with a regular form (MDIChild property set to false), however the behavior that this causes is nothing like what a true MDI Child form does.  Resizing the MDI Parent form does not cause the MDI Child form to resize within the parent if the child is maximized.  The MDI Childs menu is not merged with the parent forms menu, and a ton of other problems...

It was also suggested that we place these into ActiveX Documents, which we have done, however, it poses its own set of problems.  This does seem to be the best course of action to take, it at least works to a point.

Thanks for the response...

Are you telling me that I am wrong?\

Are you saying that My MDI form in My ActiveX EXE can no host
MDI Children?

I beg to differ.

Or is it that you are having several MDI children all by themselves in the EXE.. and you are trying to set them to a MDI Form in another app?
ah.. I misread your statement.. I did think it was odd that you were having an MDI calling another MDI with children.  

ASKER CERTIFIED SOLUTION
Avatar of lppjohns
lppjohns

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
Clever :)